Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Single SQL query for retrieval of data with different where clause possible?

 
Laxman Chowdary
Greenhorn
Posts: 21
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this



maybe this will help: http://www.sql-tutorial.ru/en/book_using_multiple_tables_in_query.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic