Joins
The JOIN
clauses are used to combine the columns of tables together when returning the results. No changes are made to the actual tables. SQL has several different types of joins, but the three most common for MySQL is INNER JOIN
, LEFT JOIN
, and RIGHT JOIN
. Each JOIN
clause is followed by the name of the second table the ON
keyword a join condition.
The INNER JOIN
will return only the rows from the two table where the join condition is met.
Note
When working with more than one table, it is sometimes necessary to specify the table along with the column using a dot syntax.
Example: table.column
SELECT books.book_title, quotes.quote,
FROM books
INNER JOIN quotes
ON books.book_id = quotes.book_id;