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

Restituisce le righe in cui la colonna corrisponde a tutti i valori in un set

Prova questa query

SELECT group_concat(`type`) AS types,user_id 
FROM users 
WHERE `type` IN('B','C') 
group by user_id 
HAVING FIND_IN_SET('B',types)>0 && FIND_IN_SET('C',types)>0 

SQL Fiddle http://sqlfiddle.com/#!2/8ef8e/2