gpt4 book ai didi

mysql - 错误代码 : 1221. UPDATE 和 ORDER BY 的使用不正确——更新表 Abonnement 时

转载 作者:行者123 更新时间:2023-11-30 22:56:19 27 4
gpt4 key购买 nike

当尝试更新以在之前制作的表格 Abonnement 中包含价格时,我收到标题中提到的错误代码。我在网上四处查看,但我的语法似乎是正确的?

SET SQL_SAFE_UPDATES=0;

DELETE FROM Abonnement;
DELETE FROM AbonnementType;

INSERT INTO AbonnementType(beginDatum,eindDatum,type)
VALUES("2013/1/1","2013/1/1","DAGPAS");

INSERT INTO Abonnement(betaald,AbonnementType_ATypeId,FietsType_FType,Klant_klantId,Code,Wachtwoord)
VALUES(false,(SELECT MAX(ATypeId) FROM AbonnementType),1,1,"test","test");

UPDATE Abonnement as a
JOIN FietsType AS af ON a.FietsType_FType = af.FType
JOIN AbonnementType AS at ON a.AbonnementType_ATypeId = at.ATypeId
SET a.prijs = af.Prijs * (at.eindDatum + at.beginDatum)
ORDER BY AbonnementId DESC
LIMIT 1;

最佳答案

您是否尝试过使用 WITH对象?

With updateSyn As
(
...
)<br/>
Update updateSyn set ...

SQL Server: UPDATE a table by using ORDER BY

关于mysql - 错误代码 : 1221. UPDATE 和 ORDER BY 的使用不正确——更新表 Abonnement 时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26217584/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com