(SQL)如何检查值是否在另一个表中?

(SQL)如何检查值是否在另一个表中?,sql,join,select,Sql,Join,Select,我对SQL不是很在行,所以我道歉 我希望能够遍历表A中的每一行,并检查表B中的整列中是否存在特定值 我希望看到表A中的所有行,其中值不在表B的特定列中 我希望这是有道理的。听起来好像不存在: select a.* from a where not exists (select 1 from b where b.col = a.col); 您可以使用不存在。你的问题有点理论性,但逻辑是: select a.* from tablea a where not exists (select 1 fr

我对SQL不是很在行,所以我道歉

我希望能够遍历表A中的每一行,并检查表B中的整列中是否存在特定值

我希望看到表A中的所有行,其中值不在表B的特定列中


我希望这是有道理的。

听起来好像不存在

select a.*
from a
where not exists (select 1 from b where b.col = a.col);

您可以使用
不存在
。你的问题有点理论性,但逻辑是:

select a.*
from tablea a
where not exists (select 1 from tableb b where b.col1 = a.col1)

其中,
tabla(col1)
中的值应与
tableb(col1)

Welcome@JoeBrown中的值相对应。如果我的答案正确回答了您的问题,请单击复选标记。谢谢