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 |
|
SpeshulK926
Starting Member
16 Posts |
Posted - 2008-09-19 : 16:44:18
|
| I have 2 tables, Red and Blue (easier to read than table1, table2, etc). In each table, I have 1 column, emailaddress.The query is off of the Blue Table. I need it to only list the ones in the Blue table where the e-mail address doesn't exist in the Red table. If the e-mail address exists in the red table, it needs to not show up. I got really confused half-way through and just need some insight.Here's the query I got so far, please be kind...select distinct(b.emailaddress) from blue bwhere not exists (select null from red rwhere b.emailaddress = r.emailaddress) order by b.emailaddressI can't tell if this is right or if this is everything... |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-20 : 01:47:58
|
| [code]SELECT b.*FROM Blue bLEFT JOIN Red rON r.emailaddress=b.emailaddressWHERE r.emailaddress IS NULL[/code]or[code]SELECT *FROM Blue WHERE emailaddress NOT IN(SELECT emailaddress FROM Red)[/code] |
 |
|
|
|
|
|