MySQL Joins

Published on Author craigzearfossLeave a comment
LEFT JOIN left-join-sm SELECT *
FROM customers
LEFT JOIN books
ON customers.book_id = books.id
RIGHT JOIN right-join-sm SELECT *
FROM customers
RIGHT JOIN books
ON customers.book_id = books.id
OUTER JOIN outer-join-sm SELECT *
FROM customers
OUTER JOIN books
ON customers.book_id = books.id
INNER JOIN
(or simply JOIN)
inner-join-sm SELECT *
FROM customers
JOIN books
ON customers.book_id = books.id
LEFT JOIN with Exclusion left-join-with-exclusion-sm SELECT *
FROM customers
LEFT JOIN books
ON customers.book_id = books.id
WHERE books.id IS NULL
RIGHT JOIN with Exclusion right-join-with-exclusion-sm SELECT *
FROM customers
RIGHT JOIN books
ON customers.book_id = books.id
WHERE customers.id IS NULL
CROSS JOIN Matches every customer with every book. SELECT *
FROM customers
CROSS JOIN books
ON customers.book_id = books.id

References:

Leave a Reply

Your email address will not be published. Required fields are marked *