oracle 使用union提示ORA-00907:缺少右括号

来源:互联网 发布:新加坡 知乎 编辑:程序博客网 时间:2024/06/06 17:24

在使用union的时候提示:ORA-00907:缺少右括号

此原因是因为在union的左边和右边都有order by,因此需要去掉一边的order by,保留一个即可。

例如:

select * from 

(

 select id,name from emp

order by name

union

 select id,name from emp


)

或者:

select * from 

(

 select id,name from emp


union

 select id,name from emp


order by name


0 0
原创粉丝点击