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 |
|
mgonda
Starting Member
29 Posts |
Posted - 2011-11-18 : 16:17:35
|
| I have a silly question, but how do you search for people not in specific cities, like Portland, Oregon or Richmond, California? I don't want to lost the people from Portland, Maine or Richmond, Virginia. If you say WHERE city NOT IN ('Portland','Richmond')AND state NOT IN ('OR','CA')doesn't that negate the entire states of California, and Oregon?Would WHERE city <> 'Portland' AND state <> 'OR'OR city <> 'Richmond' AND state <> 'CA'work? Thanks for your help. |
|
|
lionofdezert
Aged Yak Warrior
885 Posts |
Posted - 2011-11-18 : 16:30:53
|
| WHERE state NOT IN ('OR','CA')OR city IN ('Portland','Richmond')--------------------------http://connectsql.com/ |
 |
|
|
mgonda
Starting Member
29 Posts |
Posted - 2011-11-18 : 17:59:35
|
| So, maybe I'm reading that wrong, but wouldn't that then only select the cities of Portland and Richmond which aren't in those states? I am trying to select everything but Portland, OR and Ricmond, CA. |
 |
|
|
mgonda
Starting Member
29 Posts |
Posted - 2011-11-18 : 18:04:42
|
| I just reread what I wrote, and thought it sounded a little pompous, especially considering how I didn't make myself plain in my first post, so I want to apologize if that last post comes off that way. It was not intended at all. Thanks again. |
 |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2011-11-18 : 22:39:43
|
| WHERE (state <> 'OR' AND city <> 'Portland')AND (state <> 'CA' AND city <> 'Richmond') |
 |
|
|
|
|
|
|
|