日期:2014-05-19  浏览次数:20551 次

请教多表查询效率问题!
请问大侠们,多表查询时,以下两种方式哪种效率高些,原因何在?多谢指教!
1、select   a.t1,a.t2,b.t3,b.t4,c.t5,c.t6
from   biao1   a,biao2   b,biao3   c
where   a.id=b.id   and   a.id=c.id   and   a.rq= '2007-01-01 '
2、select   a.t1,a.t2,b.t3,b.t4,c.t5,c.t6
from   biao1   a   join   biao2   b   on   a.id=b.id
join   biao3   c   on   a.id=c.id
where   a.rq= '2007-01-01 '


------解决方案--------------------
方法是
在select语句前使用
declare @d datetime

set @d=getdate()

并在select语句后加:

select [语句执行花费时间(毫秒)]=datediff(ms,@d,getdate())
------解决方案--------------------
第一种没有指明联结方式,有可能产生迪卡尔集,浪费了时间。