Reputation: 1323
How can I do something like this:
SELECT *
FROM table1, table2, table3
WHERE table1.champs = table2.champs = table3.champs
And without any duplicate "champs" because at least one of the 3 tables should have duplicate lines.
Upvotes: 1
Views: 35
Reputation: 15061
INNER JOIN on your tables related fields
SELECT *
FROM table1 t1
INNER JOIN table2 t2 ON t1.champs = t2.champs
INNER JOIN table3 t3 ON t2.champs = t3.champs
Upvotes: 1
Reputation: 44805
Use modern JOIN syntax instead:
SELECT *
FROM table1
JOIN table2 ON table1.champs = table2.champs
JOIN table3 ON table2.champs = table3.champs
Duplicated rows are removed with SELECT DISTINCT
. If that's what you mean with "without any duplicate champs".
Upvotes: 3