/ code

MySQL EXPLAIN aka DESCRIBE for UPDATE/DELETE

Ever tryed to "explain" a delete or an update statement? It will fail. It took me nearly an hour to figure this out. Actually I've never needed to explain a simple DELETE statement, but in todays case I did and was wondering why my query always failed. It is too bad that there is no such "feature". With InnoDB you can use of course the ON DELETE/UPDATE stuff but in my case I didn't want to alter the existing DB.

However, if you need to delete multiple rows over multiple tables, you may do something like this: ;)

DELETE stats, links, logins
FROM promo_stats AS stats
LEFT JOIN promo_links AS links USING(promo_link_id)
LEFT JOIN promo_logins AS logins USING(promo_login_id)
WHERE stats.promo_item_id=6;
MySQL EXPLAIN aka DESCRIBE for UPDATE/DELETE
Share this