| Author |
Single SQL query for retrieval of data with different where clause possible?
|
Laxman Chowdary
Greenhorn
Joined: Apr 11, 2012
Posts: 21
|
|
I have to generate a single sql query, which retrieves two columns from two tables.
in where clause the id is 1,2,3,4 and 5.
How to form a single query with the above specified condition.
I need only sql query but not cursor or functions concept.
Eg;
select column 1, column2 from table1, table2 where id=1
select column 1, column2 from table1, table2 where id=2
select column 1, column2 from table1, table2 where id=3
select column 1, column2 from table1, table2 where id=4
How to make these multiple queries into a single query???
Thanks in Advance.
Laxman chowdary
|
 |
Wendy Gibbons
Bartender
Joined: Oct 21, 2008
Posts: 1098
|
|
I think you need to take an sql tutorial, as this is pretty basic stuff.
do you know how to link the 2 tables together?
the bit for the IDs you need in the IN operator, if you know the list of IDs.
When you have gone through a tutorial and have an sql statement that you think should work but doesn't work, feel free to come back and ask for help with the final tweaks.
|
 |
Sergey Mois
Greenhorn
Joined: Aug 25, 2009
Posts: 5
|
|
Try this
maybe this will help: http://www.sql-tutorial.ru/en/book_using_multiple_tables_in_query.html
|
 |
 |
|
|
subject: Single SQL query for retrieval of data with different where clause possible?
|
|
|