Glossary
SQL

JOIN

A JOIN is a SQL clause used to combine rows from two or more tables based on a related column between them.

Types of JOINs

INNER JOIN

Returns only rows where there is a match in both tables.

SELECT orders.id, customers.name
FROM orders
INNER JOIN customers ON orders.customer_id = customers.id;

LEFT JOIN

Returns all rows from the left table, and matched rows from the right. Non-matching right rows return NULL.

SELECT customers.name, orders.id
FROM customers
LEFT JOIN orders ON customers.id = orders.customer_id;

RIGHT JOIN

The opposite of LEFT JOIN — returns all rows from the right table.

FULL OUTER JOIN

Returns all rows when there is a match in either left or right table.

JOINs in Sequel

When you ask Sequel a question that requires data from multiple tables, it automatically generates the appropriate JOINs based on your schema's foreign key relationships.

Related terms