【发布时间】:2019-10-24 15:51:18
【问题描述】:
我是第一次更新价值。我有两张桌子。一张表有旧值,它是主表,应该更新。在第二张表中,我有新的价值观。在两个表上我都有相同的 User_ID。
数据库名称是“内网”
第一个表的名称是 'wp_bp_xprofile_data'
id field_id user_id value last_updated
59430 13 4442 598902299 22-Mar-19 20:19:54
59443 13 4443 599847428 22-Mar-19 20:19:54
59456 13 4444 598644555 22-Mar-19 20:19:54
第二张桌子的名字是'idgeorge'
user_id z9
4444 598644555
4443 599847428
4442 598902299
这是三个用户的示例,还有数千个......
我搜索了一些示例并写下了代码,但它不起作用。这是我的代码。
UPDATE wp_bp_xprofile_data
SET wp_bp_xprofile_data.value = idgeorge.z9
WHERE idgeorge.user_id = wp_bp_xprofile_data.user_id
and
wp_bp_xprofile_data.field_id=13
FROM intranet.idgeorge
报错
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'FROM 'intranet.idgeorge'' at line 11
但我无法弄清楚缺少什么或出了什么问题。
【问题讨论】:
-
一个好的提示是从 SELECT 开始。将 SELECT 转换为 UPDATE 通常相当简单。
-
下面是一个具有有效语法的查询示例。没有足够的信息来确定它是否是您正在寻找的那个...
UPDATE wp_bp_xprofile_data x JOIN idgeorge y ON y.user_id = x.user_id SET x.value = y.z9 WHERE x.field_id = 13
标签: mysql sql phpmyadmin