Page 1 of 1
Subtracting Joins
Posted: Tue Sep 14, 2004 11:57 am
by bdeonline
How can I do a Join that if the id's are the same those with equal id's won't display.
Posted: Tue Sep 14, 2004 2:07 pm
by Draco_03
I'm not sure to understand your question, a join is made when you take a value that equals another one.. that's how you actually join.
Is it a join you want to do ?
Posted: Tue Sep 14, 2004 2:09 pm
by bdeonline
It may not be a Join then but some how I got to have all the rows from one table except the ones with matching id numbers from another
Posted: Tue Sep 14, 2004 2:17 pm
by feyd
[mysql_man]left join[/mysql_man]
Code: Select all
SELECT * FROM table1 LEFT JOIN table2 ON table2.id = table1.id WHERE table2.id IS NULL
or similar....
Posted: Tue Sep 14, 2004 2:19 pm
by Calimero
Just an idea, haven't tested it:
SELECT * from * where table1.id != table2.id
Posted: Tue Sep 14, 2004 2:28 pm
by Draco_03
I though what you asked was somehting like
Code: Select all
SELECT * FROM table1, table2 WHERE t1.id <> t2.id
mhh it might not even work.. as a rules of thumb.. ALWAYS follow feyd advices

Posted: Tue Sep 14, 2004 2:36 pm
by feyd
Posted: Tue Sep 14, 2004 2:38 pm
by Draco_03
feyd wrote:LEFT JOIN looks at the data to it's left, heh, and if it doesn't match, all fields that'd normally be set, are set to NULL. So you filter it where those rows are null.. where the tables don't match..
Everything is clear
thx