Mysql
 sql >> Database >  >> RDS >> Mysql

Corrispondenza a tutti i valori nella clausola IN

Puoi fare qualcosa del genere:

select ItemID
from ItemCategory
where CategoryID in (5,6,7,8) <-- de-dupe these before building IN clause
group by ItemID
having count(distinct CategoryID) = 4 <--this is the count of unique items in IN clause above

Se fornisci il tuo schema e alcuni dati di esempio, posso fornire una risposta più pertinente.

Esempio SQL Fiddle