UPDATE seasons SET good=good+1 WHERE id = (SELECT id FROM seasons ORDER BY id DESC LIMIT 1)
When I run this command I get the error:
#1093 - Table 'seasons' is specified twice, both as a target for 'UPDATE' and as a separate source for data
UPDATE seasons SET good=good+1 WHERE id = (SELECT id FROM seasons ORDER BY id DESC LIMIT 1)
When I run this command I get the error:
#1093 - Table 'seasons' is specified twice, both as a target for 'UPDATE' and as a separate source for data
This is a MySQL limitation.
One method is to use JOIN. However, for this it is probably better to use LIMIT and ORDER BY:
UPDATE seasons s
SET s.good = s.good + 1
ORDER BY id DESC
LIMIT 1;
This does assume that id is not duplicated in the table, but that seems like a reasonable assumption for a column called id.