日期:2014-05-17  浏览次数:20906 次

关于先筛选还是后筛选?
select a1.xx,b.xx from (select a.xx from a where a.id < 100) a1 left join b on a1.id = b.id 

select a.xx,b.xx from a left join b on a.id = b.id where a.id < 100

select a.xx,b.xx from a,b where a.id(+) = b.id where a.id(+)< 100


请问以上三个语句哪个效率高?请说明原因!


------解决方案--------------------
select a.xx,b.xx from a,b where a.id(+) = b.id where a.id(+) < 100 
报错

select a1.xx,b.xx from (select a.xx from a where a.id < 100) a1 left join b on a1.id = b.id 

select a.xx,b.xx from a left join b on a.id = b.id where a.id < 100 
一样
------解决方案--------------------
效率先不说,在某些时候,执行结果是不一样的。
参照
http://hi.baidu.com/kokyu/blog/item/0ffc35cd8c4f74550fb345b6.html
http://www.diybl.com/course/7_databases/oracle/oraclejs/2008108/149307.html
------解决方案--------------------
探讨
请问在Oracle里,先执行from 然后执行where 最后再执行left join , 对吗?