Doing a little garbage collection here and using a subquery, which I know isn’t very efficient. Any pointers?
DELETE FROM `carts` WHERE `id` NOT IN (SELECT `cart_id` FROM `sessions`)
Basically it’s supposed to delete all records from my carts table that don’t have a corresponding record in the sessions table.
1 Answer