select * from “table1” A inner join “table2”B on A.id=B.AID
inner join 关联查询所取数据是 A和B的交集
select * from “table1” A full join “table2”B on A.id=B.AID
full join 关联查询所取数据是 A和B的并集,没有匹配的数据以空显示
select * from “table1” A left join “table2”B on A.id=B.AID
left join 关联查询所取数据是 A完全集,没有匹配的数据以空显示
select * from “table1” A right join “table2”B on A.id=B.AID
right join 关联查询所取数据是 以B为基础
select * from “table1” A union select * from “table2”B
select * from “table1” A unionAll select * from “table2”B
SELECT
语句必须拥有相同数量的列。列也必须拥有相似的数据类型。同时,每条
SELECT
语句中的列的顺序必须相同。
UNION
只选取记录,而
UNION ALL
会列出所有记录。
select * from “table1” A full join “table2”B on A.id=B.AID
full join 关联查询所取数据是 A和B的并集,没有匹配的数据以空显示