摘要:        
select * from A where id in (select id from B);select * from A where exists (select 1 from B where A.id=B.id);对于以上两种情况,in是在内存里遍历比较,而exists需要查询数据库,所以当B表数据量较大时,exists效率优于in。1、select * from A where id in (select id from B);in()只执行一次,它查出B表中的所有id字段并缓存起来。之后,检查A表的id是否与B表中的id相等,如果相等则将A表的记录加入结果集中,直到遍历完A表的所有记    阅读全文
        
            posted @ 2013-10-15 16:05
yl_fighting
阅读(341)
评论(0)
推荐(0)
        
        
 
                    
                     
                    
                 
                    
                 
         浙公网安备 33010602011771号
浙公网安备 33010602011771号