MySQL没有让我在UPDATE和SET命令后添加FROM命令。

我试图运行一个查询,根据一些WHERE条件从两个表中匹配行,然后将表2中的链接附加到表1中的新列中,以匹配这些行。

UPDATE
    maxpreps_player_stats AS mp
SET pbr_link = pbr.plink
FROM pbr_urls AS pbr
WHERE (LOWER(SUBSTRING(pbr.name, 1, 3)) = LOWER(SUBSTRING(mp.fullname, 1, 3))
    AND LOWER(SUBSTRING(pbr.name, -3)) = LOWER(SUBSTRING(mp.fullname, -3))
    AND LOWER(pbr.state) = LOWER(mp.team_state)
    AND LOWER(SUBSTRING(pbr.school, 1, 3)) = LOWER(SUBSTRING(mp.hsname, 1, 3))
    AND (pbr.class = mp.grad_lower_bound OR pbr.class = mp.grad_upper_bound));

但它给我的错误是:”FROM “在这个位置无效,预期是 EOF, ‘;’ 。

解决方案:

这种语法在MySql中是不支持的。你可以用这样的连接来做。

UPDATE maxpreps_player_stats AS mp
INNER JOIN pbr_urls AS pbr
ON      LOWER(SUBSTRING(pbr.name, 1, 3)) = LOWER(SUBSTRING(mp.fullname, 1, 3))
    AND LOWER(SUBSTRING(pbr.name, -3)) = LOWER(SUBSTRING(mp.fullname, -3))
    AND LOWER(pbr.state) = LOWER(mp.team_state)
    AND LOWER(SUBSTRING(pbr.school, 1, 3)) = LOWER(SUBSTRING(mp.hsname, 1, 3))
    AND (pbr.class = mp.grad_lower_bound OR pbr.class = mp.grad_upper_bound)
SET mp.pbr_link = pbr.plink;

给TA打赏
共{{data.count}}人
人已打赏
未分类

删除不再需要的文件后,如何在Docker Image中回收空间(java jdk 11用来做jre)。

2022-9-8 10:05:19

未分类

Kubectl导出已不适用。任何替代方案

2022-9-8 10:16:16

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索