其他分享
首页 > 其他分享> > union 和 union all

union 和 union all

作者:互联网

union会自动压缩多个结果集合中的重复结果,而union all则将所有的结果全部显示出来,不管是不是重复。

select
    device_id, gender, age, gpa
from user_profile
where university='山东大学'

union

select
    device_id, gender, age, gpa
from user_profile
where gender='male'
select
    device_id, gender, age, gpa
from user_profile
where university='山东大学'

union all

select
    device_id, gender, age, gpa
from user_profile
where gender='male'

 

标签:union,gender,gpa,device,id,select
来源: https://www.cnblogs.com/pangkai/p/16193292.html