Author |
Topic |
ronin2307
Posting Yak Master
126 Posts |
Posted - 2006-09-22 : 09:54:40
|
Hi,Simple question:Is there any way to write this in a shorter form:SELECT fcol like 'X' or fcol like 'Y' or fcol like 'Z'Maybe something like (which I know it won't work but just to give you an idea what I am looking for)SELECT fcol like ('X' or 'Y' or 'Z')Thanx |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-09-22 : 09:59:39
|
SELECT fcol FROM MyTablewhere fcol in ('X', 'Y', 'Z')Peter LarssonHelsingborg, Sweden |
 |
|
ronin2307
Posting Yak Master
126 Posts |
Posted - 2006-09-22 : 10:05:01
|
I see the logic but it didn't quite work. It didn't return anything even though there are entries that should be returned. Here is the whole query:select ftypefrom engecnentrieswhere ftype in ('%cone%','%basin%') |
 |
|
ronin2307
Posting Yak Master
126 Posts |
Posted - 2006-09-22 : 10:11:38
|
I now see why it is failing, but I NEED to make the use of WILD characters |
 |
|
ronin2307
Posting Yak Master
126 Posts |
Posted - 2006-09-22 : 11:45:43
|
anybody??? :-( |
 |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-09-22 : 13:59:20
|
You can't use wildcards with IN operator:select ftypefrom engecnentrieswhere ftype like '%cone%' or ftype like'%basin%' But this will be really bad, performance-wise since:1. You are using % prefix in the condition which will boil down to table scan2. You need OR conditionHarsh AthalyeIndia."Nothing is Impossible" |
 |
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2006-09-22 : 15:18:14
|
It looks like you should seriously consider using full-text indexing and queries.If you don't want to use full-text indexes, then no, there is no easier way than what you had in your original post. |
 |
|
ronin2307
Posting Yak Master
126 Posts |
Posted - 2006-09-22 : 15:26:07
|
since I have never used full-text indexing, I'll have to do some reading before I can comment. Thanx for the advice though |
 |
|
ronin2307
Posting Yak Master
126 Posts |
Posted - 2006-09-22 : 17:24:19
|
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=754544&SiteID=1&mode=1 |
 |
|
|