首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

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

2012-10-21 
能否用变量来代替一段语句有以下语句:select(select *from 表1 where 字段1(select * from 表2 where 字

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

热点排行