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

请问这两个语句有区别吗
select   a.col1   from   a
left   join   b   on   a.id=b.id
where   b.date= '2007-1-1 '


select   a.col1   from   a
left   join   b   on   a.id=b.id  
and   b.date= '2007-1-1 '

如果没有区别,执行效率上那个更好啊
谢谢

------解决方案--------------------
Create Table A
(ID Int)
Create Table B
(ID Int,
Date Varchar(10))
GO
Insert A Select 1
Union All Select 2
Union All Select 3

Insert B Select 1, '2007-1-1 '
Union All Select 2, '2007-1-1 '
Union All Select 3, '2007-1-2 '
GO
select a.id from a
left join b on a.id=b.id
where b.date= '2007-1-1 '


select a.id from a
left join b on a.id=b.id
and b.date= '2007-1-1 '

GO
Drop Table A, B
--Result
/*
id
1
2

id
1
2
3
*/