0

我有以下查询

SELECT abm_took_id FROM pos_took WHERE DELETEDDATE IS NOT NULL

abm_took_id它从 table获取值pos_took

现在有另一个表pos_eook,它由作为外键的列组成cbm_bookid,即第一个表的 ( pos_took) 主键abm_took_id是第二个表 ( pos_eook) 的外键cbm_bookid

现在我必须检查abm_took_id从第一个查询引用中提取的是否存在于第二个表中,例如abm_took_id=44555从第一个查询中提取,现在它是否存在于第二个表中,请告知我可以在哪里使用或存在运算符的查询.

4

1 回答 1

1

如果您试图在第一个表(查询)中查找不在第二个表中的所有引用:

SELECT abm_took_id
FROM pos_took
WHERE DELETEDDATE IS NOT NULL and
      abm_took_id not in (select cbm_bookid
                          from pos_eook
                          where cbm_bookid is not null
                         );
于 2013-09-09T15:43:58.770 回答