两个关于SQL语句的问题,急,马上给分!
查询一是否执行了两次?有其他的解决办法吗?(必须查询出table表中所有记录并用"是,否"标识,并不允许有重复)
select c_1,c_2,c_3,'是'as role from t_table where c_1 = "条件1" /*查询一*/
union
select c_1,c_2,c_3, '否' as role from t_table where c_1 not in(select c_1 from t_table where c_1 = "条件1")
以下两句哪一个效率更高一些?是否有更好的解决办法?
select b_id,b_name from b where b_id in(select a_id as b_id from a)
select a.a_id,b.b_name from a,b where a.a_id = b.b_id
问题点数:42、回复次数:7Top
1 楼KingSunSha(弱水三千)回复于 2001-09-27 12:19:37 得分 20
1. oracle pl/sql:
select c_1, c_2, c_3, decode(c_1,'条件1','是','否') as role
from t_table;
2. 论坛有关于相同问题的讨论, 请参考
Top
2 楼tccb()回复于 2001-09-27 12:20:44 得分 7
查询一可以写一个user define function,根据c1,返回yes,no
问题二效率与a,b表记录数有关。我觉得第二个效率高Top
3 楼zhuzhichao(竹之草)回复于 2001-09-27 12:21:48 得分 10
select c_1,c_2,c_3,case c_1 when "条件1" then '是' else '否' end
from t_table;Top
4 楼dull_knife(学无止境)回复于 2001-09-27 12:22:07 得分 5
为何不这样写 select a.a_id,b.name
from a
inner join b
on a.a_id=b.b_id
----------------------------------
select a.a_id,b.b_name from a,b where a.a_id = b.b_id执行较快.
Top
5 楼zhuzhichao(竹之草)回复于 2001-09-27 12:24:11 得分 0
弱水兄真快.Top
6 楼progame(www.progame.org)回复于 2001-09-27 12:25:30 得分 0
又来迟了:(Top
7 楼progame(www.progame.org)回复于 2001-09-27 12:26:20 得分 0
你们都在这蹲点啊:(Top




