Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on problem in select statement within the MY SQL forums, part of the Databases category; i want to retrieve data from two tables,but in single row i want these. suppose there r two tables,in which deptid are foreignkey,where deptid=10,i want one name from table,& where ...
|
|||||||
|
|||
|
i want to retrieve data from two tables,but in single row i want these.
suppose there r two tables,in which deptid are foreignkey,where deptid=10,i want one name from table,& where deptid=20,I want another name,please verify this."urjent" |
| Sponsored Links |
|
|||
|
Re: problem in select statement
select a.column1, b. column2 from table1 a , table2 b whre a.depid = 20
you can include as many columns you want considering table1 as a , and table 2 as b.. just add the column names as in table... |
|
|||
|
Re: problem in select statement
I guess this should help
Select a.deptid, b.deptid, b.name from table1 a, table2 b where a.deptid = b.deptid and b.deptid = 20 or b.deptid = 10 |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Can Select statement be used along with Update statement? | pankit | SQL | 6 | 01-15-2009 06:19 AM |
| Is this a correct statement | anoop4real | C and C++ | 13 | 05-22-2008 06:22 AM |
| Why we have to close connection, statement, prepared statement | Geek_Guest | Java | 8 | 02-27-2008 06:09 AM |
| Select within select | neeraj_sigh | SQL | 7 | 12-09-2007 03:59 AM |
| Evaluate SQL statement | Geek_Guest | Oracle | 1 | 09-30-2007 06:04 AM |