join
NATURAL JOIN
Matches using all identically named columns; here only k is shared. Schema changes can silently alter the predicate. Prefer explicit ON or USING in maintained queries.
Formal Syntax & Structure
sql syntaxsql
a NATURAL JOIN bWorking Example
Example Snippetsql
CREATE TABLE a(id INTEGER PRIMARY KEY, k INTEGER); CREATE TABLE b(bid INTEGER PRIMARY KEY, k INTEGER); INSERT INTO a VALUES (1,10),(2,20),(3,NULL),(4,10); INSERT INTO b VALUES (101,10),(102,10),(103,30),(104,NULL);SELECT a.id,b.bid FROM a NATURAL JOIN b ORDER BY a.id NULLS LAST,b.bid NULLS LAST;