MySQL union 和 union all的区别
适用情况: 对于多个具有相同字段表查询后想要返回为同一张表,即按列合并时
区别: union all是把结果集直接合并在一起不做任何处理,而union 是将union all后的结果进行一次distinct,去除重复的记录后的结果。
举例:
假设有两个表分别存储了语文和数学考试的分数,表中数据如下所示。
表一:Chinese
name
score
xiaoming
80
xiaohong
78
xiaowen
92
表二:Math
name
score
xiaom
原创
2022-04-03 11:00:39 ·
6858 阅读 ·
0 评论