我有一个名为 questions 的表,其中包含列(id、标题、消息、永久链接)
。我想根据值 title
更新 permalink
列,并用下划线替换标题中的空格。
这是我的查询:
UPDATE questions AS q SET permalink = SUBSTRING_INDEX(REPLACE(LOWER(b.title),' ','_'), '_', 4) FROM questions AS b;
但是我收到以下错误:
#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 questions AS b' at line 1
最佳答案
您的查询在单行上运行。您不需要别名或额外的选择,只需:
UPDATE questions
SET permalink = SUBSTRING_INDEX(REPLACE(LOWER(title),' ','_'), '_', 4):
关于mysql - 根据同一个表中的值更新 Mysql 表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59965759/