急!!在线等

shrek11 2007-10-31 11:17:34
优化数据库语句:
select * from eosoperator where operatorid in(select studentid from student where classid in(select classid from class where ishistoryclass=0))
在线等啊
...全文
135 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
GEPIN 2007-10-31
  • 打赏
  • 举报
回复
联机帮助上不是有写么:当子查询里有in or exists语句,使用JOIN语句,效率要高么?
况且效率高不高和你的数据量,索引结构都有关。
shrek11 2007-10-31
  • 打赏
  • 举报
回复
我马上测试一哈,
把结果给大家看看
谢谢你们拉
dobear_0922 2007-10-31
  • 打赏
  • 举报
回复
select E.*   
from eosoperator E join
(select distinct studentid
from student B join (select classid from class where ishistoryclass=0) C on B.classid=C.classid) T
on E.operatorid=T.studentid
OracleRoob 2007-10-31
  • 打赏
  • 举报
回复


--try

select a.*
from eosoperator a
inner join
(select studentid from student b inner join classwhere c on b.classid = c.classid where c.ishistoryclass=0 group by studentid) as t
on a.operatorid = t.studentid
dobear_0922 2007-10-31
  • 打赏
  • 举报
回复
用大家的方法,如果eosoperator表有1条记录,最终可能会查出10条来,,,
dobear_0922 2007-10-31
  • 打赏
  • 举报
回复
回完贴发现是三位了,,,
OracleRoob 2007-10-31
  • 打赏
  • 举报
回复
select a.* 
from eosoperator a
inner join student b on a.operatorid = b.studentid
inner join classwhere c on b.classid = c.classid
where c.ishistoryclass=0
dobear_0922 2007-10-31
  • 打赏
  • 举报
回复
楼上两位的方法会有重复记录
OracleRoob 2007-10-31
  • 打赏
  • 举报
回复
用关联吧,效率高些
pt1314917 2007-10-31
  • 打赏
  • 举报
回复


select a.* from eosoperator a,student b,class c where a.operatorid=b.studentid and b.classid=c.classid
and c.ishistoryclass=0
toddzst 2007-10-31
  • 打赏
  • 举报
回复
就是,觉得LS的2位方法就可以,为什么非用子查询
xiangyu120 2007-10-31
  • 打赏
  • 举报
回复
select a.* from eosoperator a,student b,class c where a.operatorid=b.studentid and b.clssid=c.callssid and c.ishistoryclass=0
dawugui 2007-10-31
  • 打赏
  • 举报
回复
试试

select a.*
from eosoperator a, student b,classwhere c
where a.operatorid = b.studentid and b.classid = c.classid and c.ishistoryclass=0
中国风 2007-10-31
  • 打赏
  • 举报
回复


select
*
from
eosoperator
where
exists(select 1 from student where student=eosoperator.operatorid
exists(select 1 from class where ishistoryclass=0 and classid=student.classid))
中国风 2007-10-31
  • 打赏
  • 举报
回复
用取真的方法测测:
select
*
from
eosoperator
where
exists(select 1 from class where ishistoryclass=0 and
exists(select 1 from student where classid=class.classid and student=eosoperator.operatorid) )

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧