Mysql
 sql >> Datenbank >  >> RDS >> Mysql

MySQL-Filter auf Viele-zu-Viele

Versuchen Sie dies

SELECT r.id, r.name, GROUP_CONCAT(DISTINCT(i.name)) as items
 FROM receipts r
 LEFT JOIN receipts-ingredients ri ON(ri.receipt_id = r.id)
 LEFT JOIN ingredients i ON(ri.ingredient_id = i.id)
 GROUP BY r.id
 HAVING FIND_IN_SET('tomato',items) AND FIND_IN_SET('pesto',items)