擅长:python、mysql、java
<p>只需使用熟悉的<code>LEFT JOIN... IS NULL / NOT EXISTS / NOT IN</code>的纯SQL解决方案。下面是在MS Access中兼容的等效查询,根据<em>col1</em>和<em>col2</em>返回TableA中而不是TableB中的行。在</p>
<p><strong>左连接…为空</strong></p>
<pre class="lang-sql prettyprint-override"><code>SELECT a.*
FROM TABLEA a
LEFT JOIN TABLEB b
ON a.col1 = b.col1 AND a.col2 = b.col2
WHERE b.col1 IS NULL AND b.col2 IS NULL
</code></pre>
<p><strong>不存在</strong></p>
^{pr2}$
<p><strong>不在</strong></p>
<pre class="lang-sql prettyprint-override"><code>SELECT a.*
FROM TABLEA a
WHERE a.col1 NOT IN (SELECT col1 FROM TABLEB)
AND a.col2 NOT IN (SELECT col1 FROM TABLEB)
</code></pre>