当前位置: 代码迷 >> Oracle管理 >> 可否用变量来代替一段语句
  详细解决方案

可否用变量来代替一段语句

热度:6   发布时间:2016-04-24 05:02:08.0
能否用变量来代替一段语句
有以下语句:
select 
(select * from 表1 where 字段1=(select * from 表2 where 字段2='01') and 字段3='高级') a,
(select * from 表1 where 字段1=(select * from 表2 where 字段2='01') and 字段3='中级') b,
(select * from 表1 where 字段1=(select * from 表2 where 字段2='01') and 字段3='初级') c
from dual

能否用什么变量之类的来代替 (select * from 表2 where 字段2='01') 或者 变量= (select * from 表2 where 字段2='01')
即写成
select 
(select * from 表1 where 字段1=变量 and 字段3='高级') a,
(select * from 表1 where 字段1=变量 and 字段3='中级') b,
(select * from 表1 where 字段1=变量 and 字段3='初级') c
from dual

具体怎么写,我不大懂这些的语法

------解决方案--------------------
探讨
有以下语句:
select
(select * from 表1 where 字段1=(select * from 表2 where 字段2='01') and 字段3='高级') a,
(select * from 表1 where 字段1=(select * from 表2 where 字段2='01') and 字段3='中级') b,
(select * from 表1 wh……
  相关解决方案