MySQL Delete from 1 table, using multiple tables
- by nute
I would like to delete all the rows found by that query:
SELECT cart_abandon.*
FROM cart_abandon, cart_product, txn_product, users
WHERE cart_abandon.cartid = cart_product.cartid
AND cart_product.productid = txn_product.productid
AND txn_product.username = users.username
AND users.id = cart_abandon.userid
AND txn_product.txndate >= cart_abandon.abandondate
The thing to keep in mind is that the query here uses 4 different tables, however I only want to delete rows from 1 table (cart_abandon).
Is there an easy way to do that? Maybe this: ?
DELETE cart_abandon
FROM cart_abandon, cart_product, txn_product, users
WHERE cart_abandon.cartid = cart_product.cartid
AND cart_product.productid = txn_product.productid
AND txn_product.username = users.username
AND users.id = cart_abandon.userid
AND txn_product.txndate >= cart_abandon.abandondate
Is that valid? Correct?