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.
Author |
Topic |
allan8964
Posting Yak Master
249 Posts |
Posted - 2012-06-06 : 10:21:25
|
Hi there,I need to grab some items into a where clause, see below:table1ID | Location 10| New York11| Dallas...select * from table2 where Location = 'New York' or Location = 'Dallas' ...How can I select Location from table1 to where clause in table2?Thanks in advance. |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-06-06 : 10:23:47
|
select * from table2 where location in (select distinct location from table1) No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-06-06 : 10:23:48
|
select * from table2 where Location in (select location frrom table)orselect t2.*from table2 t2join table1 t1on t1.location = t2.location==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
allan8964
Posting Yak Master
249 Posts |
Posted - 2012-06-06 : 10:31:31
|
Thanks webfred and nigelrivett, I never thought it's this simple! Thanks again. |
|
|
|
|
|