赞
踩
SELECT *
FROM table1
JOIN table2 ON table1.column_name = table2.column_name;
也可以使用 INTERSECT 关键字
SELECT * FROM table1
INTERSECT
SELECT * FROM table2;
SELECT * FROM table1
UNION
SELECT * FROM table2;
-- 左表中有的而右表中没有的
SELECT table1.*
FROM table1
LEFT JOIN table2 ON table1.column_name = table2.column_name
WHERE table2.column_name IS NULL;
-- 右表中有的而左表中没有的
SELECT table2.*
FROM table1
RIGHT JOIN table2 ON table1.column_name = table2.column_name
WHERE table1.column_name IS NULL;
也可以使用 except关键字
SELECT * FROM table1
except
SELECT * FROM table2;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。