我有2张桌子。首先"product" (id)
。第二- "product_has_option_value" (product_id, option_value_id)
。
我怎样才能获得id
没有一些的产品option_value_id
(例如 10)?“product_has_option_value”具有多对多关系。
好的。我想我找到了解决方案:
select p.id
from product p
where p.id not in
(select distinct(product_id)
from product_has_option_value
where option_value_id=543)
Run Code Online (Sandbox Code Playgroud)