您好,欢迎来到爱go旅游网。
搜索
您的当前位置:首页数据库之集合查询

数据库之集合查询

来源:爱go旅游网
集合查询

一、并查询(union)

    格式:
select ...........
from 表1 left join 表2
on........
union
select ...........
from 表2 right join 表2
on........
    作用:
求两个select的并集,去掉重复项
    注意:
两个表的字段数和数据类型相同
二、交查询(intersect)
    格式
(select ...........
from .......
where........)
intersect
(select ...........
from........
where........)
    作用:
求两个select的交集
    注意:
两个表的字段数和数据类型相同,mysql不支持
三、差查询(minus/except) 
格式1(oracle):
select ...........
from .......
where........
minus
select ...........
from........
where........
格式2(sql server):
select ...........
from .......
where........
except
select ...........
from........
where........
    作用:
找出满足第一个select并不满足第二个select的数据
    注意:
两个表的字段数和数据类型相同,mysql不支持

 

转载于:https://www.cnblogs.com/SoulReaper/p/3309800.html

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- igat.cn 版权所有 赣ICP备2024042791号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务