Full answer
Three ways to say "match on the key":
CREATE TABLE dept (dept_id INTEGER, dept_name TEXT);
CREATE TABLE staff (staff_name TEXT, dept_id INTEGER);
INSERT INTO dept VALUES (1,'Library'),(2,'Canteen');
INSERT INTO staff VALUES ('Ira',1),('Jon',2),('Kim',1);ON is the general form. Any condition works, and both key columns stay available with their table prefixes:
SELECT s.staff_name, d.dept_name
FROM staff s JOIN dept d ON d.dept_id = s.dept_id
ORDER BY s.staff_name;| staff_name | dept_name |
|---|---|
| Ira | Library |
| Jon | Canteen |
| Kim | Library |
USING (id) requires a column with the same name in both tables, compares them with =, and returns it once without a prefix. It reads nicely when keys share names, which these tables do not, so here is a tiny pair that does:
SELECT dept_id, staff_name, dept_name
FROM staff JOIN dept USING (dept_id)
ORDER BY staff_name;| dept_id | staff_name | dept_name |
|---|---|---|
| 1 | Ira | Library |
| 2 | Jon | Canteen |
| 1 | Kim | Library |
NATURAL JOIN goes further and joins on every column name the tables have in common:
SELECT staff_name, dept_name FROM staff NATURAL JOIN dept ORDER BY staff_name;| staff_name | dept_name |
|---|---|
| Ira | Library |
| Jon | Canteen |
| Kim | Library |
It works today. Then someone adds an updated_on column to both tables for auditing:
ALTER TABLE dept ADD COLUMN updated_on TEXT DEFAULT '2026-01-01';
ALTER TABLE staff ADD COLUMN updated_on TEXT DEFAULT '2026-02-15';
SELECT staff_name, dept_name FROM staff NATURAL JOIN dept ORDER BY staff_name;| staff_name | dept_name |
|---|
(0 rows)
The same NATURAL JOIN now also requires updated_on to match, and the rows vanish without any error. The query text never changed. That is why style guides often ban NATURAL JOIN in application code. USING is generally considered safe, because the join columns are written down.
CREATE TABLE dept (dept_id INTEGER, dept_name TEXT);
CREATE TABLE staff (staff_name TEXT, dept_id INTEGER);
INSERT INTO dept VALUES (1,'Library'),(2,'Canteen');
INSERT INTO staff VALUES ('Ira',1),('Jon',2),('Kim',1);
SELECT s.staff_name, d.dept_name
FROM staff s JOIN dept d ON d.dept_id = s.dept_id
ORDER BY s.staff_name;
SELECT dept_id, staff_name, dept_name
FROM staff JOIN dept USING (dept_id)
ORDER BY staff_name;
SELECT staff_name, dept_name FROM staff NATURAL JOIN dept ORDER BY staff_name;
ALTER TABLE dept ADD COLUMN updated_on TEXT DEFAULT '2026-01-01';
ALTER TABLE staff ADD COLUMN updated_on TEXT DEFAULT '2026-02-15';
SELECT staff_name, dept_name FROM staff NATURAL JOIN dept ORDER BY staff_name;Checked on SQLite 3.46.1, run twice with identical output.
Key points
- ON accepts any condition
- USING (col) is equality on same-named columns, output once
- NATURAL JOIN picks join columns automatically from shared names
- A new common column name can silently change a NATURAL JOIN
Common mistakes
- Using NATURAL JOIN in code that lives for years
- Expecting USING to work when key columns have different names
Follow-ups
- Can you mix USING with extra conditions?
- How do you refer to the USING column in SELECT on PostgreSQL?
Tips
- Tell the audit-column story; it is the concrete reason behind the rule