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