其他分享
首页 > 其他分享> > Oralce报错--查询块具有不正确的结果列数

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' ;

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

标签:Oralce,--,a1,union,报错,table,where,select
来源: https://www.cnblogs.com/YC-L/p/14764186.html