Eerste idee (onder vele anderen die precies hetzelfde hadden):
DELETE FROM orders
WHERE order_id =
( SELECT MAX(order_id)
FROM orders
)
Helaas klaagt MySQL met:
> ERROR 1093 (HY000): You can't specify target table 'orders' for update in FROM
> clause
Twee manieren om de fout te omzeilen:
DELETE FROM orders
WHERE order_id =
( SELECT maxo
FROM
( SELECT MAX(order_id) AS maxo
FROM orders
) AS tmp
)
of:
DELETE FROM orders
ORDER BY order_id DESC
LIMIT 1