SELECT DISTINCT ad_id
FROM
(SELECT ad_id
FROM Producst
WHERE (property_id = 4 AND property_value_id = 1)
OR (property_id = 7 AND property_value_id = 6)
OR (property_id = 6 AND property_value_id = 3)
group by ad_id
having count(ad_id) = 3) as subquery
select distinct a.ad_id
from my_table a
join my_table b on b.ad_id = a.ad_id
join my_table c on c.ad_id = a.ad_id
where a.property_id = 4 and a.property_value_id = 1
or b.property_id = 7 and b.property_value_id = 6
or c.property_id = 6 and c.property_value_id = 3
2条答案
按热度按时间bjp0bcyl1#
应该做的工作。
rslzwgfq2#
您可以将表格与其本身链接三次,每对搜寻值链接一次。查询的格式如下: