gpt4 book ai didi

mysql - mySQL 更新查询中的语法错误

转载 作者:行者123 更新时间:2023-11-29 12:06:12 25 4
gpt4 key购买 nike

我尝试执行查询但收到错误。这是我的查询:

UPDATE 
prepares_for_exam
SET
prepares_for_exam.exam_id = product.id
FROM
prepares_for_exam,
product
WHERE
prepares_for_exam.id = product.prepares_for_exam_id

我收到错误:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM prepares_for_exam, product WHERE prepares_for_exam.id = product.prepares_fo' at line 1

我使用 FROM 子句执行了 100 次更新查询,但从未遇到过问题...我的错是什么?!?

最佳答案

您正在使用 SQL-Server 语法。在 MySQL 中,情况略有不同。

UPDATE 
prepares_for_exam
JOIN
product
ON
prepares_for_exam.id = product.prepares_for_exam_id
SET
prepares_for_exam.exam_id = product.id

关于mysql - mySQL 更新查询中的语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31435569/

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