日期:2014-05-17  浏览次数:20829 次

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