Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 sql query 2

Author  Topic 

kabucek
Starting Member

7 Posts

Posted - 2008-10-15 : 14:04:53
hi @ll,

is it possible to display data from tables,
but with given values for certain colums?
for example:

select * from 'table1', 'table2', 'table3' where table2.itemID=['003', '005', '009'];

- I don't know the syntax , this is just my idea

thanks

hanbingl
Aged Yak Warrior

652 Posts

Posted - 2008-10-15 : 14:07:36
yes, use itemID in ('003','005','009')


Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-10-15 : 14:09:37
Yes, you can use IN. Remove the single quotes around the table names.

itemID IN ('003', '005', '009')

You'll likely need to add a join condition. In your example, you'd do this in the WHERE clause.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -