HOME/📦 INBOX/

【🔎 SQL】様々なJOIN

Article Outline
TOC
Collection Outline

|| INNER JOIN句

書き方

SELECT *
FROM table_a AS a
INNER JOIN table_b AS b
ON a.id = b.id;

|| LEFT OUTER JOIN句

書き方

SELECT *
FROM table_a AS a
LEFT JOIN table_b AS b
ON a.id = b.id;

|| RIGHT OUTER JOIN句

書き方

SELECT *
FROM table_a AS a
RIGHT JOIN table_b AS b
ON a.id = b.id;

|| FULL OUTER JOIN句

書き方

SELECT *
FROM table_a AS a
FULL OUTER JOIN table_b AS b
ON a.id = b.id;

|| SELF JOIN句

書き方

SELECT *
FROM table_a AS a1
INNER JOIN table_a AS a2
ON a1.id = a2.id;

|| CROSS JOIN句

imgSQL CROSS JOIN with examples - SQLShack

書き方

SELECT *
FROM table_a AS a
CROSS JOIN table_b AS b;

こんなことして何が嬉しいの?

Cf.