读书人

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

发布时间: 2012-10-21 09:00:07 作者: rapoo

能否用变量来代替一段语句
有以下语句:
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……

读书人网 >oracle

热点推荐