一、union 模块不能出现order 、limit语句
- 报错内容:mismatched input 'union'. Expecting: ')', ',', 'FETCH', 'LIMIT', 'NULLS', 'OFFSET'
- 报错原因:union语法中出现 order by
- 解决办法:嵌套一层子查询,将排序放到外侧
---eg:
select*from
(
select *from a
union
select*from b
)t
order by d
二、union 和union all
- union 去重,union all不去重