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 |
|
Barryt82
Starting Member
1 Post |
Posted - 2012-02-07 : 17:10:23
|
| select * from candidates where candidate_id not in(select owner_id from addresses where country in ('Ericsson','Uganda','Ghana','Kenya','Tanzania'))select * from candidates where candidate_id in (select owner_id from addresses where country not in ('Ericsson','Uganda','Ghana','Kenya','Tanzania'))hi in the above code, would both give the same result? the only difference is where the 'in' and 'not' are placed. is it possible to switch them around and see the same results?Thanks |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
Kristen
Test
22859 Posts |
Posted - 2012-02-07 : 17:20:46
|
Note that if owner_id CAN be NULL then ... where candidate_id not in(select owner_id from addresses ... will return nothing if one/many of the values of [candidate_id] IS NULL. That will give you a very specific difference between the two! on the other hand IN will not be bothered by one/many values being NULL in the list. |
 |
|
|
|
|
|