I am trying to set a particular value to the last row in a table, but I'm not sure how to do this with subqueries. I am getting the sid of the last row in the table by
SELECT sid ORDER BY timestamp DESC LIMIT 1
and I want to assign "bar" to the foo column of that sid.
This is what I have so far, but it does not work (#1235 - This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery').
UPDATE table SET foo="bar" WHERE sid IN (SELECT sid ORDER BY timestamp DESC LIMIT 1)
Any ideas?
Thanks!
You don't need a subquery at all. :)
UPDATE `table` SET `foo` = 'bar' ORDER BY `timestamp` DESC LIMIT 1;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.