MySQL DELETE with a Max() Subquery

Here is a nifty way to use a SubQuery when deleting a record from your MySQL table.

The following MySQL code will delete a record from "table1" where the slot is equal to the MAX() value of slot from "table2".

DELETE FROM table1 WHERE slot = (SELECT MAX(slot) FROM table2);

Tags: