我需要一些帮助......
在“帖子”表中,我确实有两列,我需要将一个字段的值提取/移动到另一个字段中,并将其与现有值合并。
Table name: posts
-------------------
post_title | post_name
-------------------------------
Title | ashgt-36548
Some title | ahrgz-46587
Some other title | kkahe-55486
post_name 的值都采用相同的格式:5 个字母加上破折号“-”和 5 个数字(-DIGITS)。
所以我需要获得的是:
从 post_name 中删除“-DIGITS”并将其注入到 post_title 字段(合并值)的最开始(第一个位置),删除“-”并将 5 位数字括在括号中 [DIGITS]+SPACE
因此结果应如下所示:
Table name: posts
--------------------------------------
post_title | post_name
--------------------------------------
[36548] Title | ashgt
[46587] Some title | ahrgz
[55486] Some other title | kkahe
到目前为止,我从 post_name 中删除破折号和数字的 SQL 语法是(我确实通过另一列“maschinen”进行选择):
UPDATE posts
SET `post_name`= mid(`post_name`, 1,length(`post_name`)-6)
WHERE `post_name` LIKE '%-%' AND `post_type` LIKE 'maschinen';
任何帮助都将非常有帮助 - 谢谢。