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 |
SQLIsTheDevil
Posting Yak Master
177 Posts |
Posted - 2007-10-31 : 10:52:26
|
Is there an efficient query for selecting all but x values in a column? Say I have a table with a column called named Category. In this column, I have the values: Birthday, Wedding, Halloween, Christmas, Baby Shower, Engagement, and SuperBowl. Keep in mind, these values will be listed multiple times, but those are the distinct values discussed.Now I want to select all values in the table where Category is equal to all the values shown except 1. In general, all but X would be nice, too. Instead of doing something like this: select *from table1where Category = 'Halloween' or Category = 'Birthday' or ...I'd like to make a query that accomplishes the task I set out with as little overhead as possible. Is it possible or must I specify each individual value I need in my query?thank you. |
|
jhocutt
Constraint Violating Yak Guru
385 Posts |
Posted - 2007-10-31 : 10:55:22
|
where category <> ' 'Birthday'or where category != 'Birthday'"God does not play dice" -- Albert Einstein"Not only does God play dice, but he sometimes throws them where they cannot be seen." -- Stephen Hawking |
 |
|
SQLIsTheDevil
Posting Yak Master
177 Posts |
Posted - 2007-10-31 : 11:33:27
|
LOL Thanks for making me feel like a complete jackass. |
 |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-10-31 : 14:10:30
|
you can also use not in (...)_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenpSSMS Add-in that does a few things: www.ssmstoolspack.com |
 |
|
|
|
|