小编pet*_*tey的帖子

在oracle中连接三个表或执行嵌套的sql语句

连接三个表或在oracle中执行嵌套的sql

我有三张桌子:gut,pos和cfg

肠和pos共享一个值,可以使用连接 gut.gut_val= pos.pos_val.

类似地,cfg和pos表共享一个值,并且可以使用以下内容进行连接:cfg.cfg_dev_cot = pos.pos_dev_val.

然而,cfg和gut不会共享一个值.我想要做的是显示gut_cou,pos_mon_runch和cfg_cfg_cou的值,当 gut_val = pos_val和时cfg_dev_cot = pos_dev_val.有没有办法用连接执行此操作,还是最好是执行嵌套的sql语句?

我试过的是以下但它抛出了一个oracle错误.

select gut.gut_cou, pos.pos_mon_runch, cfg.cfg_cou
from gut,pos,cfg
where gut.gut_val = pos.pos_val
and cfg.cfg_dev_cot = pos.pos_dev_val
and pos.POS_CIT='12345654'
and gut.gut_DAT_DEB <= '08-AUG-11'
and gut.gut_DAT_FIN >= '08-AUG-11'
and gut.gut_TCV ='BOU' 
Run Code Online (Sandbox Code Playgroud)

sql database oracle select join

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

database ×1

join ×1

oracle ×1

select ×1

sql ×1