You can't specify target table 'fact' for update in FROM clause code example

Example 1: update you can't specify target table for update in from clause

UPDATE myTable
SET myTable.A =
(
    SELECT B
    FROM (SELECT * FROM myTable) AS something
    INNER JOIN ...
)

Example 2: mysql #1093 - You can't specify target table error

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
)

Tags:

Misc Example