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 |
|
WJHamel
Aged Yak Warrior
651 Posts |
Posted - 2012-02-09 : 09:13:29
|
| i'm attempting to do the following:USE ARRESTSELECT * FROM arrest WHERE ecsoid = 'GCSO00MNI000524', 'GCSO00MNI006163','GCSO00MNI032352'I actually have about 153 ECSOID numbers from a table that i need to select into a single new table. Obviously the above won't work. how do i accomplish this?thanks |
|
|
singularity
Posting Yak Master
153 Posts |
Posted - 2012-02-09 : 09:15:39
|
| [code]SELECT * FROM arrest WHERE ecsoid in ('GCSO00MNI000524', 'GCSO00MNI006163','GCSO00MNI032352')[/code] |
 |
|
|
WJHamel
Aged Yak Warrior
651 Posts |
Posted - 2012-02-09 : 09:23:39
|
| thanks |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-02-09 : 14:01:40
|
quote: Originally posted by WJHamel i'm attempting to do the following:USE ARRESTSELECT * FROM arrest WHERE ecsoid = 'GCSO00MNI000524', 'GCSO00MNI006163','GCSO00MNI032352'I actually have about 153 ECSOID numbers from a table that i need to select into a single new table. Obviously the above won't work. how do i accomplish this?thanks
if numbers are coming from a table then why list the values in select again inside IN. why not simply join to table or use EXISTS?USE ARRESTSELECT a.* FROM arrest aINNER JOIN ECSOIDNumbertable tON t.ecsoid = a.ecsoid orUSE ARRESTSELECT a.* FROM arrest aWHERE EXISTS(SELECT 1 FROM ECSOIDNumbertable tWHERE t.ecsoid = a.ecsoid ) ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|