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'如果没有区别,执行效率上那个更好啊
谢谢
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'如果没有区别,执行效率上那个更好啊
谢谢
(ID Int)
Create Table B
(ID Int,
Date Varchar(10))
GO
Insert A Select 1
Union All Select 2
Union All Select 3Insert 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
2id
1
2
3
*/
(ID Int)
Create Table B
(ID Int,
Date Varchar(10))
GO
Insert A Select 1
Union All Select 2
Union All Select 3Insert 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
inner join b on a.id=b.id
where b.date='2007-1-1'
select a.id from a
inner join b on a.id=b.id
and b.date='2007-1-1'
GO
Drop Table A, B
--Result
/*
id
1
2id
1
2
*/