在 SQL 中连接表可以使用 JOIN 关键字来实现。常用的连接方式有:
SELECT *
FROM table1
INNER JOIN table2
ON table1.column = table2.column;
SELECT *
FROM table1
LEFT JOIN table2
ON table1.column = table2.column;
SELECT *
FROM table1
RIGHT JOIN table2
ON table1.column = table2.column;
SELECT *
FROM table1
FULL JOIN table2
ON table1.column = table2.column;
还可以使用子查询或者关联子查询来连接表:
SELECT *
FROM table1
WHERE column IN (SELECT column FROM table2);