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 |
|
ravilobo
Master Smack Fu Yak Hacker
1184 Posts |
Posted - 2005-03-24 : 10:33:15
|
| CREATE TABLE tt (data varchar(10))INSERT ttSELECT 'aaaa'UNIONSELECT 'bbbb'UNIONSELECT 'cccc'UNIONSELECT 'dddd'SELECT data FROM tt WHERE data NOT IN ('a%','b%')The above query is not returning the expected output. It is returning 4 records. I am expecting 2. How can i modify the query?------------------------I think, therefore I am |
|
|
PW
Yak Posting Veteran
95 Posts |
Posted - 2005-03-24 : 10:37:01
|
| NOT LIKE instead of NOT IN |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2005-03-24 : 10:37:05
|
EDIT: Damn, 4 secondsSELECT data FROM tt WHERE data NOT LIKE 'a%'AND data NOT LIKE 'b%'Brett8-) |
 |
|
|
ravilobo
Master Smack Fu Yak Hacker
1184 Posts |
Posted - 2005-03-24 : 10:46:13
|
| I know that will work. But i have a long list to be put in the filter. The approach you have suggested may not be efficient, i will use that if there is no alternative...------------------------I think, therefore I am |
 |
|
|
ravilobo
Master Smack Fu Yak Hacker
1184 Posts |
Posted - 2005-03-24 : 10:53:42
|
| Got it.SELECT data FROM tt WHERE data NOT LIKE '[ab]%'------------------------I think, therefore I am |
 |
|
|
PW
Yak Posting Veteran
95 Posts |
Posted - 2005-03-24 : 10:58:53
|
| >>The approach you have suggested may not be efficient,Uhh, I didn't suggest it, you did in your original post. If you'd posted that your problem was efficiency in *addition* to incorrect results ...>>i will use that if there is no alternative...There are alternatives. |
 |
|
|
|
|
|