问题
I got the following code:
Update `Table` set amount='1003' WHERE date = (SELECT MIN(date)) AND `id` = 736
Something is wrong with my first Where rule date = (SELECT MIN(date))
but i dont know what.
回答1:
You can update it from a join:
Update `Table` a
INNER JOIN (
SELECT `id`, min(exp_date) AS exp_date from `Table` WHERE `id`= 736
) AS b ON (a.id=b.id AND a.exp_date=b.exp_date)
set amount='1003'
WHERE a.id = 736 AND a.exp_date=b.exp_date;
来源:https://stackoverflow.com/questions/40171682/sql-update-table-where-date-mindate