sql 判断一个表的数据不在另一个表中
时间:2021-07-01 10:21:17
帮助过:34人阅读
1
SELECT a.
* FROM a
LEFT JOIN b
ON a.
key = b.
key WHERE (b.
key IS NULL)
--2
select *,
case when (
select count(
*)
from b
where id
= a.id)
>0 then 1 else 0 end as flag
from a
--3
select id
from (
select a.id,b.conid
from a
left join b
on a.id
=b.conid)
as res
where res.conid
is null
select id
from a
where id
not in (
select conid
from b)
--4
select id,mian
=(
case when isnull(a.mian,
‘‘)
=‘‘ then b.mian
else a.mian
end)
from a
left join b
on a.id
=b.id
sql 判断一个表的数据不在另一个表中
标签:pre div bsp sql when ase join else code