我有这个陈述,我不知道如何使用if或case进行组合
insert into tlp (given_name, namel, email)
select
first_name, namel, mail
from
glob
where
(not exists (select email from tlp where (glob.mail = tlp.email)))
and glob.mail is not null;
insert into tlp (given_name, namel, email)
select
first_name, namel, mail
from
glob
where
(not exists (select namel from tlp where (glob.namel = tlp.namel)))
and glob.mail is null;
如果要将两个插入片段转换为一个插入片段,请尝试这样的操作。
INSERT INTO tlp
(given_name,
namel,
email)
SELECT first_name,
namel,
mail
FROM glob
WHERE ( NOT EXISTS (SELECT email
FROM tlp
WHERE glob.mail = tlp.email )
AND glob.mail IS NOT NULL )
OR ( NOT EXISTS (SELECT namel
FROM tlp
WHERE glob.namel = tlp.namel )
AND glob.mail IS NULL )
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句