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 |
|
albertkohl
Aged Yak Warrior
740 Posts |
Posted - 2007-03-26 : 13:25:49
|
| is there any way to incorporate a like and an in () together?for example, i want to pull all of the companies that match a list i have (10 companies) the normal way i would do this is just union together 10 quries, and basically query up each company, one by phone. |
|
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2007-03-26 : 13:35:42
|
| You'll have to use OR to put the LIKE tests togetherSELECT ...FROM yourtableWHERE col1 LIKE 'string1%' OR col1 LIKE 'string2%' OR col1 LIKE 'string3%' OR col1 LIKE 'string4%' OR col1 LIKE 'string5%' OR col1 LIKE 'string6%' OR col1 LIKE 'string7%' OR col1 LIKE 'string8%' OR col1 LIKE 'string9%' OR col1 LIKE 'string10%' |
 |
|
|
albertkohl
Aged Yak Warrior
740 Posts |
Posted - 2007-03-26 : 13:44:17
|
| ouch, so no way really to work a like and an in together hu? okay, well i guess i could always just use excel to concant the statements. thank you! |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
LoztInSpace
Aged Yak Warrior
940 Posts |
Posted - 2007-03-26 : 19:53:29
|
| something like select a.* from ainner join(select 'string1%' z union allselect 'string2%' union allselect 'string3%') b on a.z like b.z |
 |
|
|
|
|
|