NOT EXIST和NOT IN 和MINUS的用法
Posted yangjinprocess
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了NOT EXIST和NOT IN 和MINUS的用法相关的知识,希望对你有一定的参考价值。
MINUS
SELECT count(id) FROM householdstaffs s WHERE s.idcardno in(
SELECT h.idcardno FROM householdstaffs h WHERE h.orginternalcode like ‘1.1.9.9.%‘
Minus
SELECT hs.idcardno FROM [email protected]_db hs WHERE hs.orginternalcode like ‘1.1.9.9.%‘)
AND s.orginternalcode like ‘1.1.9.9.%‘;
NOT IN
SELECT count(id) FROM householdstaffs h
WHERE h.idcardno NOT IN ( SELECT idcardno FROM [email protected]_db hs WHERE hs.orginternalcode like ‘1.1.9.9.%‘ )
AND h.orginternalcode like ‘1.1.9.9.%‘;
NOT EXIST
SELECT count(id) FROM householdstaffs h
WHERE
NOT EXISTS (
SELECT idcardno
FROM [email protected]_db hs
WHERE hs.idcardno = h.idcardno AND hs.orginternalcode like ‘1.1.9.9.%‘)
AND h.orginternalcode like ‘1.1.9.9.%‘;
以上是关于NOT EXIST和NOT IN 和MINUS的用法的主要内容,如果未能解决你的问题,请参考以下文章