1.
a. 并集UNION
SELECT column1, column2 FROM table1
UNION
SELECT column1, column2 FROM table2
b. 交集JOIN
SELECT * FROM table1 AS a JOIN table2 b ON a.name=b.name
c. 差集NOT IN
SELECT * FROM table1 WHERE name NOT IN(SELECT name FROM table2)
d. 笛卡尔积
SELECT * FROM table1 CROSS JOIN table2
与
SELECT * FROM table1,table2相同
2. SQL中的UNION
UNION与UNION ALL的区别是,前者会去除重复的条目,后者会仍旧保留。
阅读全文
类别: 程序 查看评论
a. 并集UNION
SELECT column1, column2 FROM table1
UNION
SELECT column1, column2 FROM table2
b. 交集JOIN
SELECT * FROM table1 AS a JOIN table2 b ON a.name=b.name
c. 差集NOT IN
SELECT * FROM table1 WHERE name NOT IN(SELECT name FROM table2)
d. 笛卡尔积
SELECT * FROM table1 CROSS JOIN table2
与
SELECT * FROM table1,table2相同
2. SQL中的UNION
UNION与UNION ALL的区别是,前者会去除重复的条目,后者会仍旧保留。
阅读全文
类别: 程序 查看评论