ORA-01789:query block has incorrect number of result columns

来源:互联网 发布:淘宝哪有弩卖 编辑:程序博客网 时间:2024/06/02 09:25


在写一个8张表一起union all 的SQL时,遇到了ORA-01789:query block has incorrect number of result columns


顾名思义,查询块的列数目不相等


下面的SQL,查询时就会报ORA-01789错误

select empno, ename, job, sal from emp t where t.deptno = 20unionselect empno, ename, sal from emp t where t.deptno = 30

补上第二个块的列,补齐了就可以正常查询了。

select empno, ename, job, sal  from emp t where t.deptno = 20unionselect empno, ename, 'job', sal  from emp t where t.deptno = 30


0 0
原创粉丝点击