阅读背景:

SQL ON子句v WHERE子句(不同的结果)

来源:互联网 

Please see the DDL below:

请参阅下面的DDL:

CREATE TABLE TestTable(id int, [name] varchar(30))
CREATE TABLE TestTable2(id int, [name] varchar(30))

INSERT INTO TestTable (id,[name]) values (1,'')
INSERT INTO TestTable (id,[name]) values (2,'Martin')

INSERT INTO TestTable2 (id,[name]) values (1,null)
INSERT INTO TestTable2 (id,[name]) values (2,'Martin')

select TestTable.* from TestTable
LEFT JOIN TestTable2 
ON TestTable.id=TestTable2.id 
and TestTable.[name]= TestTable2.[Name] and NOT (TestTable.[name] ='' and TestTable2.[name] is null)
where testtable2.id is null
CREATE



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: