user1286819
user1286819

Reputation: 91

Multiple DELETE in mysql not working with alias

I used this scheme for a multiple DELETE

DELETE Table1, Table2, Table3
FROM   Table1
JOIN   Table2 ON (Table2.ConditionID = Table1.ConditionID)
JOIN   Table3 ON (Table3.ConditionID = Table2.ConditionID)
WHERE  Table1.ConditionID = ?;

Why can't I use aliasnames like this

DELETE Table1, Table2, Table3
FROM   Table1 t1
JOIN   Table2 t2 ON (t2.ConditionID = t1.ConditionID)
JOIN   Table3 t3 ON (t3.ConditionID = t2.ConditionID)
WHERE  t1.ConditionID = ?;

I only get a normal Syntaxerror.

Upvotes: 0

Views: 107

Answers (1)

John Woo
John Woo

Reputation: 263943

Actually you can, you just need to use the ALIAS name given after the DELETE keyword.

DELETE  t1, t2, t3
FROM    Table1 t1
        JOIN   Table2 t2 ON (t2.ConditionID = t1.ConditionID)
        JOIN   Table3 t3 ON (t3.ConditionID = t2.ConditionID)
WHERE   t1.ConditionID = ?;

Upvotes: 2

Related Questions