gpt4 book ai didi

mysql - 使用 PHPMYADMIN 更新

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

下午好,

我正在尝试使用另一个表中的价格数据更新表,但是使用内部联接时出现错误。我确信这是非常愚蠢的事情,但我已经在这上面花费了一天中最好的时间,现在是寻求帮助的时候了。

如果我执行以下 SELECT 语句来测试我的内部联接语法是否正常工作

SELECT *
FROM polaracc_osrs_property_field_value
INNER JOIN polaracc_osrs_properties
ON polaracc_osrs_property_field_value.pro_id = polaracc_osrs_properties.id
WHERE polaracc_osrs_property_field_value.field_id =112

但是,当我尝试使用一个表中的价格运行更新语句来填充第二个表时,出现以下错误

1064 - 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 polaracc_osrs_property_field_value INNER JOIN polaracc_osrs_properties ' at line 3

更新语句使用的语法如下

UPDATE polaracc_osrs_property_field_value 
SET polaracc_osrs_property_field_value.value_integer = polaracc_osrs_properties.price
FROM polaracc_osrs_property_field_value
INNER JOIN polaracc_osrs_properties
ON polaracc_osrs_property_field_value.pro_id = polaracc_osrs_properties.id
WHERE polaracc_osrs_property_field_value.field_id = 112

最佳答案

您需要先加入,然后再设置值,如下所示:

UPDATE polaracc_osrs_property_field_value
INNER JOIN polaracc_osrs_properties
ON polaracc_osrs_property_field_value.pro_id = polaracc_osrs_properties.id
SET polaracc_osrs_property_field_value.value_integer = polaracc_osrs_properties.price
WHERE polaracc_osrs_property_field_value.field_id = 112;

希望这有帮助。

关于mysql - 使用 PHPMYADMIN 更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36623286/

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