【发布时间】:2020-08-30 15:24:54
【问题描述】:
我有这个问题
SELECT SUBSTRING(post_content,INSTR(post_content, '[table'),16) as substring,
ID FROM `wp276_posts`
WHERE `post_content` LIKE '%[table%'
AND `post_status` = 'publish'
ORDER BY `ID` ASC
返回这个结果:
如何只选择子字符串的数字部分?
例如需要的结果:
+-----------+------+
| substring | ID |
+-----------+------+
| 22 | 5072 |
+-----------+------+
| 67 | 5757 |
+-----------+------+
| 54 | 8550 |
+-----------+------+
【问题讨论】:
-
请展示 post_content 的例子
-
您没有使用 substring_index 的事实表明您当前的查询可能不是最佳的..
-
post_content 是一个 WordPress 帖子,可能是一切。如果找到以[table开头的字符串,我需要取id=后面的数字