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 |
|
MJ1210
Starting Member
3 Posts |
Posted - 2008-06-09 : 17:07:55
|
| Hi,I remember seeing a fancy query that checked for multiple fields in a table (I think using a select statement in the where clause but not sure), but can't remember how to do it... here is what I want to do (and maybe there is a much easier way). Thanks!Table1id item color1 shoe red2 shoe blue3 coat green4 coat blackTable2item colorshoe redcoat greenI want everything in Table1 where item and color are not a match.So my results should be:2 shoe blue4 coat blackI'm sorry if this is a dumb question... it's been that kind of a day!Thanks! |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-06-09 : 17:11:20
|
| SELECT t1.id, t1.item, t1.colorFROM Table1 t1LEFT OUTER JOIN Table2 t2ON t1.item = t2.item AND t1.color = t2.colorWHERE t2.item IS NULL and t2.color IS NULLTara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog |
 |
|
|
|
|
|