select a1,a2 from a where a1 in (select a1 from b)
1,我想用如下代替,效率是否可以提高?效率最高的是哪种?
select a.a1,a.a2 from a,b where a.a1=b.a1
2,如果在in后面的子查询里面有order by 子句,对外部的查询结果来说有意义吗?
...全文
1036打赏收藏
关于in的两个问题
例如: select a1,a2 from a where a1 in (select a1 from b) 1,我想用如下代替,效率是否可以提高?效率最高的是哪种? select a.a1,a.a2 from a,b where a.a1=b.a1 2,如果在in后面的子查询里面有order by 子句,对外部的查询结果来说有意义吗?
1、
子查询 select a1,a2 from a where a1 in (select a1 from b)
的效率比
连接查询select a.a1,a.a2 from a,b where a.a1=b.a1
的效率高。
2、
在in后面的子查询里面有order by 子句,对外部的查询结果来说无意义