对多表联合查询的性能对比

啵比 2011-05-04 11:59:25
网上的资料:
常用的多表联合查询的sql语句:
select table1.ID from table1 inner join table2 on table1.ID=table2.ID
where table2.col2='xxx'

改进后:
select a.ID from table1 a,
(select col1,ID from table2 where col2='xxx') b
where a.ID=b.ID

请大家解释一下,这两个东西有什么区别吗?
...全文
168 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
--小F-- 2011-05-04
  • 打赏
  • 举报
回复
查看执行计划吧

第二种方法在使用索引方面还要差些
昵称被占用了 2011-05-04
  • 打赏
  • 举报
回复
这不能算改进,只能算倒退

在2005+,这个修改毫无意义,即执行效果完全一样
在低板本,或许有用
啵比 2011-05-04
  • 打赏
  • 举报
回复
[Quote=引用楼主 lonelyxmas 的回复:]
网上的资料:
常用的多表联合查询的sql语句:
select table1.ID from table1 inner join table2 on table1.ID=table2.ID
where table2.col2='xxx'

改进后:
select a.ID from table1 a,
(select col1,ID from table2 where col2='xx……
[/Quote]

听说如果table2数据量庞大有效???真的假的?呀
xuexiaodong2009 2011-05-04
  • 打赏
  • 举报
回复
一个是连接,一个是子查询,查询结果一样,在mssql中一样

34,588

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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