更新时间:2022-12-18 09:07:16
通常,您可以在UPDATE
语句中使用LIMIT
和ORDER
,但对于您而言,则不能如
Usually you can use LIMIT
and ORDER
in your UPDATE
statements, but in your case not, as written in the MySQL Documentation 12.2.10. UPDATE Syntax:
对于多表语法,UPDATE会更新每个名为的表中的行 在满足条件的table_references中.在这种情况下,订购 不能使用BY和LIMIT.
For the multiple-table syntax, UPDATE updates rows in each table named in table_references that satisfy the conditions. In this case, ORDER BY and LIMIT cannot be used.
请尝试以下操作:
UPDATE Ratemaster
SET Ratemaster.Rate =
(
SELECT Rates.Rate
FROM Rates
WHERE Ratemaster.user = Rates.user
ORDER BY Rates.id
LIMIT 1
)