表A:
id
表B id_b
表C id_icselect decode(a.id_type,
1,(select b.b_desc from B b where b.id_b=a.id_a),
2,(select c.c_desc from C c where c.id_c=a.id_a)
) discription,
a.*
from A a
这条语句还可以怎么写?不用decode,兄弟们多多发贴,多多益善
id
表B id_b
表C id_icselect decode(a.id_type,
1,(select b.b_desc from B b where b.id_b=a.id_a),
2,(select c.c_desc from C c where c.id_c=a.id_a)
) discription,
a.*
from A a
这条语句还可以怎么写?不用decode,兄弟们多多发贴,多多益善
解决方案 »
- oracle 11g 监听器无法启动。输入 lsnrctl status无显示
- 为什么我的Database Configuration Assistant不能启动?
- -- 使用存储过程的好处 --
- 紧急~~~我重启AIX服务器,怎么我的Oracle启动不了了??救命!
- PL/SQL DEV中的command window是不是可以取代SQL PLUS?
- oracle10客户端配置
- 请问ORACLE从哪个版本开始支持XML?哪个版本支持的较好?
- 关于表空间扩展问题。
- oracle for linux 是否免费?
- 在线等比较急,新建了一个数据库然后错误了,之前的数据库备份不了提示:UDE-12560
- SQL中如何调用返回类型为record的函数
- 我想在这个存储过程的游标中加条件,根据输入的值进行判断,请大家帮我修改以下,总是报错
from a
left join b on b.id_b=a.id_a
left join c on c.id_c=a.id_a
不过,最好不要楼主的这种子查询,1楼的左连接更好
你可以用union连接
select b.b_desc description,a.*
from A a,B b
where a.id_a=b.id_b and a.id_type=1
union
select c.c_desc description,a.*
from A a,C c
where a.id_a=c.id_c and a.id_type=2
select nvl((select b.b_desc
from B b
where b.id_b = a.id_a
and a.id_type = 1),
(select c.c_desc
from C c
where c.id_c = a.id_a
and a.id_type = 2))) discription, a.*
from A a