Oracle with as ORA-00903: invalid table name 多表报错

今天遇到了一个问题 with as 多次使用会报错!!

网上查了资料好多都不行!

order是保留字,如果不小心用了order这个单词就只能加上双引号 "order"   操作

 

题目 是这个 

第一次我尝试单表使用with as 正常运行!!

with sss as (select cc.cname,cc.cid abcd,ss.sid from course cc,sc scc,student ss where cc.cid=scc.cid and scc.sid=ss.sid and ss.sid=01)
  2  select * from sss
  3  ;

CNAME      ABCD       SID
---------- ---------- ----------
数学       02         01
语文       01         01
英语       03         01
 

with t as (select cc.cname,cc.cid abcd,ss.sid from course cc,sc scc,student ss where cc.cid=scc.cid and scc.sid=ss.sid and ss.sid!=01)
  2  select * from t;

CNAME      ABCD       SID
---------- ---------- ----------
英语       03         02
数学       02         02
语文       01         02
体育       04         03
英语       03         03
数学       02         03
语文       01         03
体育       04         04
英语       03         04
体育       04         04
语文       01         04

CNAME      ABCD       SID
---------- ---------- ----------
数学       02         05
英语       03         05
英语       03         06
语文       01         06
体育       04         07
数学       02         07
英语       03         07
 

但我想要 2表联查时 出现以下错误

with sss as (select cc.cname,cc.cid abcd,ss.sid from course cc,sc scc,student ss where cc.cid=scc.cid and scc.sid=ss.sid and ss.sid=01),
with t as (select cc.cname,cc.cid abcd,ss.sid from course cc,sc scc,student ss where cc.cid=scc.cid and scc.sid=ss.sid and ss.sid!=01)
  2    3  select * from t,sss;
with t as (select cc.cname,cc.cid abcd,ss.sid from course cc,sc scc,student ss where cc.cid=scc.cid and scc.sid=ss.sid and ss.sid!=01)
*
ERROR at line 2:
ORA-00903: invalid table name

 

 

翻译很清楚 无效的表名 !!(表名明明是对的怎么就无效了????) 

后来发现多了个 wtih  去掉之后成功

SQL> ;
  1  with sss as (select cc.cname,cc.cid abcd,ss.sid from course cc,sc scc,student ss where cc.cid=scc.cid and scc.sid=ss.sid and ss.sid=01),
  2  with t as (select cc.cname,cc.cid abcd,ss.sid from course cc,sc scc,student ss where cc.cid=scc.cid and scc.sid=ss.sid and ss.sid!=01)
  3* select * from t,sss
with sss as (select cc.cname,cc.cid abcd,ss.sid from course cc,sc scc,student ss where cc.cid=scc.cid and scc.sid=ss.sid and ss.sid=01),
t as (select cc.cname,cc.cid abcd,ss.sid from course cc,sc scc,student ss where cc.cid=scc.cid and scc.sid=ss.sid and ss.sid!=01)
  2    3  select * from t,sss;

CNAME      ABCD       SID        CNAME      ABCD       SID
---------- ---------- ---------- ---------- ---------- ----------
英语       03         02         语文       01         01
英语       03         02         数学       02         01

 

注意点1 多表 with as  去掉后面的

 

注意点2 多表 with as  中间加逗号

数据就成功查出来了!!!!!!!!!!!!! 

  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kjshuan

点个赞就好啦!!!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值