Mysql 试图用另一个表列的值替换列的值
这是我到目前为止得到的结果,但它是错误的:MySQLMysql 试图用另一个表列的值替换列的值,mysql,Mysql,这是我到目前为止得到的结果,但它是错误的:MySQL UPDATE item_template_epix SET armor = (SELECT armor FROM item_template) WHERE entry IN (SELECT entry FROM item_template WHERE armor > 1); 错误: 我想你需要这样的东西: UPDATE item_template_epix JOIN item_temp
UPDATE item_template_epix
SET armor =
(SELECT armor
FROM item_template)
WHERE entry IN (SELECT entry FROM item_template WHERE armor > 1);
错误:
我想你需要这样的东西:
UPDATE item_template_epix
JOIN item_template ON item_template_epix.entry = item_template.entry
SET item_template_epix.armor = item_template.armor
WHERE item_template.armor > 1
你可以试试这个
UPDATE item_template_epix SET (armor) = (WITH OneValue AS
(SELECT entry FROM item_template Where armor > 1))
SELECT armor FROM OneValue);
正如错误所说,您的子查询将返回多行。您需要将每个查询限制都排在前1位,或者添加一些其他查询限制以将它们减少到一行。搜索“sql update with JOIN”。事实上,您告诉它使用许多其他值更新表中的每个值,这是行不通的。我尝试对整个列而不是一行执行此操作。该列中的每个单元格都需要指定一个值。是的,这就是问题所在。我有两个表,我正试图从另一个表导入列值[Err]1064-您的SQL语法有错误;检查与您的MySQL服务器版本相对应的手册,以了解第3Yeh行的near'FROM item_template_epix JOIN item_template ON item_template_epix.entry=item_'使用的正确语法。。。这是SQL server语法,您应该指定它是MySQL。但似乎MySQL语法非常接近,请尝试我的更新答案。不幸的是,错误是:您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,了解使用第1行的“armor=WITH OneValue AS SELECT armor FROM item_template Where armor”的正确语法。您可以详细介绍如何/为什么这样做来回答请求者的问题吗?使用OneValue AS作为Oracle属性,我刚刚注意到您有MySQL平台。对不起,误会了。这对你不起作用
UPDATE item_template_epix SET (armor) = (WITH OneValue AS
(SELECT entry FROM item_template Where armor > 1))
SELECT armor FROM OneValue);