我正在尝试找出具有短代码的页面 ID。这是我试图在 mysql phpmyadmin
SELECT ID FROM wp_posts WHERE post_type = "page" AND post_status="publish" AND post_content LIKE "%[registration id="17"]%"
但是显示如下错误
#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 '17"]%"
在第 1 行限制 0、25'
提前致谢。
最佳答案
你的sql有问题
SELECT ID FROM wp_posts WHERE post_type = "page" AND
post_status="publish" AND post_content LIKE "%[registration id="17"]%"
^^^^^^
在 where like 部分使用 '
而不是 "
。
SELECT ID FROM wp_posts WHERE post_type = "page" AND
post_status="publish" AND post_content LIKE "%[registration id='17']%"
如果你真的想匹配
注册id="17"
,尝试转义"
。
SELECT ID FROM wp_posts WHERE post_type = "page" AND
post_status="publish" AND post_content LIKE "%[registration id=\"17\"]%"
或
SELECT ID FROM wp_posts WHERE post_type = "page" AND
post_status="publish" AND post_content LIKE '%[registration id="17"]%'
关于Mysql 查询在 phpmyadmin 中显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33116582/