[thelist] SQL: Negative Join?
Sean G.
ethanol at mathlab.sunysb.edu
Sun Sep 28 20:49:18 CDT 2003
Howdy,
Joshua was spot on with his reply. I just want to butt in with a quick remark
as to why your query was not the solution to your problem.
>
>SELECT k.columns
>FROM keepers k
>LEFT JOIN tossers t
> ON k.client <> t.client;
>
There's nothing wrong with using an inequality, or any other criteria, in a
JOIN. However, in this case let's say k.client contains:
Joe
Bob
Sue
and t.client contains:
Joe
Frank
Kelly
Bob
Bob is in both lists, but Bob <> Joe. Also, Bob <> Frank and Bob <> Kelly.
So while you could ask, give me any and all clients from k where there exists a
client from t that is not equal, what you really want is, give me clients from
k where there does not exist a client from t that is equal.
HTH,
Sean G.
More information about the thelist
mailing list