1、错误描述
[Err] 1222 - The used SELECT statements have a different number of columns
[SQL]SELECT t.id,t.eage,t.ename,t.esex FROM emp t
UNION ALL
SELECT s.age,s.`name`,s.id FROM t_stu_info s;
[Err] 1222 - The used SELECT statements have a different number of columns
2、错误原因
SELECT t.id,t.eage,t.ename,t.esex FROM emp t
UNION ALL
SELECT s.age,s.`name`,s.id FROM t_stu_info s;
两个查询SQL语句用union all连接,但是字段个数不一致,导致出错
3、解决办法
(1)根据需求,下面一个select添加个字段
(2)第一个select中删除一个字段