合并查询的字段数量要一样,而且对应的字段类型要一样
select id,username from member
union
select student_id,sdudent_name from student2;
有排序,limit一类的子句,应该将联合的查询分别用括号括起来
(select id,username from member order by username desc limit 3)
union
(select student_id,sdudent_name from student2 limit 2)
联合可以加all和distinct(默认,有区别)限定字,保留或去除重复记录
select id from member
union distinct
select student_id from student2