UNION operator must have an equal number of expressions

来源:互联网 发布:上海正规驾校排名知乎 编辑:程序博客网 时间:2024/05/17 23:58

做SQL统计报表的时候,调试报错如下:


Msg 205, Level 16, State 1, Line 1

All queries combined using a UNION, INTERSECT or EXCEPT operator must have an equal number of expressions in their target lists.



说明:select *from table_A  union [all]  select *from table_B 


解决方案:联合查询union [all] 函数必须 table_A 与 table_B 的列字段数量一致 

比如table_A有5个字段,table_B有3个字段,使用union all会出现如上错误提示



0 0
原创粉丝点击