SELECT item.idItem, detail.idDetail, detail.title FROM item
JOIN details_item ON item.idItem = details_item.idItem
JOIN detail ON detail.idDetail = details_item .idDetail
WHERE detail.title in ("Железо","Дерево","Медь")
SELECT item.title FROM (
SELECT
item.idItem
FROM item
JOIN details_item ON item.idItem = details_item.idItem
JOIN detail ON detail.idDetail = details_item .idDetail
GROUP BY item.idItem
HAVING sum(CASE
WHEN detail.title in ("Железо","Дерево","Медь")
THEN 1
ELSE 0 END) = 3
) t
JOIN item ON item.idItem = t.idItem
select item.idItem
from item
where
count (SELECT details_item.idItem FROM details_item
JOIN detail ON detail.idDetail = details_item .idDetail
WHERE detail.title = "Железо"
and details_item.idItem = item.idItem) > 0
and
count (SELECT details_item.idItem FROM details_item
JOIN detail ON detail.idDetail = details_item .idDetail
WHERE detail.title = "Дерево"
and details_item.idItem = item.idItem) > 0
and
count (SELECT details_item.idItem FROM details_item
JOIN detail ON detail.idDetail = details_item .idDetail
WHERE detail.title = "Медь"
and details_item.idItem = item.idItem) > 0
.... и так далее, все обязательные критерии прописываем через подзапрос count()
select idItem
from (select item.idItem,
count (SELECT details_item.idItem FROM details_item
JOIN detail ON detail.idDetail = details_item .idDetail
WHERE detail.title = "Железо"
and details_item.idItem = item.idItem) as count_1,
count (SELECT details_item.idItem FROM details_item
JOIN detail ON detail.idDetail = details_item .idDetail
WHERE detail.title = "Дерево"
and details_item.idItem = item.idItem) as count_2,
count (SELECT details_item.idItem FROM details_item
JOIN detail ON detail.idDetail = details_item .idDetail
WHERE detail.title = "Медь"
and details_item.idItem = item.idItem) as count_3
.... и так далее все обязательные критерии через подзрапрос count(...) as count_n
from item)
where count_1 > 0 and count_2 > 0 and count_3 > 0 -- строгое соответствие параметрам поиска
-- тут делаем логику нечувствительности к одному из параметров поиска
or count_1 = 0 and count_2 > 0 and count_3 > 0
or count_1 > 0 and count_2 = 0 and count_3 > 0
or count_1 > 0 and count_2 > 0 and count_3 = 0