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

Wie wähle ich Einträge aus dieser Beziehung aus?

Probieren Sie so etwas aus:

SELECT * 
FROM `feed_entries`
WHERE id IN (
    SELECT e.id
    FROM `feed_entries` AS `e` 
    INNER JOIN `feeds` AS `f` ON e.feed_id =f.id 
    INNER JOIN `entries_categorias` AS `ec` 
    ON ec.entry_id =e.id INNER JOIN `categorias` AS `c` 
    ON ec.categoria_id =c.id 
    WHERE c.nome IN ('Google','Apple') 
    AND (e.deleted =0)
    GROUP BY e.id
    HAVING COUNT(DISTINCT ec.id) = 2
)