MySQL - Abfrage über drei Tabellen

Hmm irgendwie sowas:

SQL:
DELETE FROM s_categories, s_articles_categories USING (SELECT categoryID, articleID, s_articles.active ,count(*) as Anzahl, s_categories.description 
FROM `s_articles_categories`
INNER JOIN s_articles ON s_articles_categories.articleID=s_articles.id 
INNER JOIN s_categories ON s_articles_categories.categoryID=s_categories.id 
GROUP BY categoryID 
HAVING sum(s_articles.active)=0) t
WHERE s_categories.id=t.categoryID OR s_articles_categories.id=t.articleID

Bei dem WHERE mußt du mal schauen.
 
Zurück