我的 MySQL 语句有什么问题?

发布于 2024-08-15 15:57:49 字数 311 浏览 6 评论 0原文

UPDATE table1 SET announcer = ( SELECT memberid
FROM ( table1
JOIN users ON table2.username = table1.announcer
) AS a
WHERE a.username = table1.announcer )

#1064 - 您的 SQL 语法有错误;检查手册 对应你的MySQL服务器 正确使用语法的版本 靠近“某个地方” a.用户名=table1.播音员)' 在第 1 行

UPDATE table1 SET announcer = ( SELECT memberid
FROM ( table1
JOIN users ON table2.username = table1.announcer
) AS a
WHERE a.username = table1.announcer )

#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 'a where
a.username=table1.announcer)'
at line 1

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

此刻的回忆 2024-08-22 15:57:49

尝试:

UPDATE announcements a
SET announcer =
(SELECT memberid
FROM users u
WHERE u.username = a.announcer)

Try:

UPDATE announcements a
SET announcer =
(SELECT memberid
FROM users u
WHERE u.username = a.announcer)
铜锣湾横着走 2024-08-22 15:57:49

您还可以在更新中进行加入

UPDATE announcements JOIN users
SET announcements.announcer=users.memberid
WHERE announcements.username=users.username;

注意:出于安全原因(直到您确定的播音员被正确复制),我会创建一个新列,然后说anouncerNew

UPDATE announcements JOIN users
SET announcements.announcerNew=users.memberid
WHERE announcements.username=users.username;

You can also do the JOIN in the UPDATE

UPDATE announcements JOIN users
SET announcements.announcer=users.memberid
WHERE announcements.username=users.username;

Note: For safty reasons (until your sure announcers get copied over right) I'd instead create a new column, say announcerNew then

UPDATE announcements JOIN users
SET announcements.announcerNew=users.memberid
WHERE announcements.username=users.username;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文