Loading

Oralce报错--查询块具有不正确的结果列数

Oracle数据库在执行一条带有union的sql语句时报如下错误

 

这是union的结果集查询的列不一致导致的,比如说

select t.a, t.b, t.c from table t where t.a='abc' 
union
select t.a1, t.1b, t.c1 from table1 t1 where t.a1='ddd' ;

这种是不会报错的,但是下面这个例子就会报上面的错误

select t.a, t.b, t.c from table t where t.a='abc' 
union
select t.1b, t.c1 from table1 t1 where t.a1='ddd' ;

列数不一致会导致这种错误。

posted @ 2021-05-17 09:44  BigBender  阅读(706)  评论(0编辑  收藏  举报