SELECT B.代号,B.NAME FROM B LEFT JOIN A ON B.NAME=A.NAME WHERE A.NAME IS NULL
SELECT * FROM TB WHERE NOT EXISTS (SELECT 1 FROM TA WHERE 项目 =TB.NAME)
select * from 表b b where not exists( select * from 表a where name=b.name )
select a.* from a right join b on a.name=b.name where a.name is nullselect * from b where name not in(select name from a)select * from b where not exists(select 1 from a where a.name=b.name)
使用exists效率最高。 select * from b where not exists(select 1 from a where a.name=b.name)
select * from b where not exists(select 1 from a where a.项目=b.name and a.代号=b.代号)
SELECT B.代号,B.NAME
FROM B LEFT JOIN A ON B.NAME=A.NAME
WHERE A.NAME IS NULL
(SELECT 1 FROM TA WHERE 项目 =TB.NAME)
where not exists(
select * from 表a where name=b.name
)
select a.* from a right join b on a.name=b.name
where a.name is nullselect * from b where name not in(select name from a)select * from b where not exists(select 1 from a where a.name=b.name)
select * from b where not exists(select 1 from a where a.name=b.name)