Queries of the following type can not be run on
MySQL, because in a DELETE query you can not specify the same table both on FROM and on WHERE:
DELETE FROM story_category
WHERE category_id NOT IN (
SELECT DISTINCT category.id AS cid FROM category
INNER JOIN story_category ON category_id=category.id
)
We must therefore modify the query as follows:
DELETE FROM story_category
WHERE category_id NOT IN (
SELECT cid FROM (
SELECT DISTINCT category.id AS cid FROM category
INNER JOIN story_category ON category_id=category.id
) AS c
)
Nessun commento:
Posta un commento