SQL关键字 except和except all的含义和区别

来源:互联网 发布:淘宝店铺运营服务商 编辑:程序博客网 时间:2024/05/29 13:53

except、except all 都是取集合的差集; 它们的区别在于except取差集后会删除重复项,而except all 不删除重复项。 下面是举例说明:

表et1

a

--

1

2

3

2


表et2

b

---

 1

 3

 

except执行结果:

mybase=# select a from et1 except select b from et2;

 a

---

 2

(1 行)

 

except all执行结果:

mybase=# select a from et1 except all select b from et2;

 a

---

 2

 2

(2 行)


原创粉丝点击