首页 > 文章列表 > MySQL使用UNION的注意点有哪些?

MySQL使用UNION的注意点有哪些?

mysql union
150 2023-04-26

1、union操作符用于连接两个以上的select语句的结果组合到一个结果集合中。多个select语句会删除重复的数据。

2、在使用时union合并结果集时,要求两个结果集的列数相同。

实例

select playerno, town
from PLAYERS
where town = 'Inglewood'
union
select playerno, town
from PLAYERS
where town = 'Plymouth';