我正在尝试查找具有短代码的页面ID。这是我试图在mysql 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}}
LIMIT 0,25'在第1行
提前致谢。
答案 0 :(得分:3)
你的sql有问题
SELECT ID FROM wp_posts WHERE post_type = "page" AND
post_status="publish" AND post_content LIKE "%[registration id="17"]%"
^^^^^^
在where where part中使用'
代替"
。
SELECT ID FROM wp_posts WHERE post_type = "page" AND
post_status="publish" AND post_content LIKE "%[registration id='17']%"
如果你真的想要匹配
registration id="17"
,请尝试逃避"
。
SELECT ID FROM wp_posts WHERE post_type = "page" AND
post_status="publish" AND post_content LIKE "%[registration id=\"17\"]%"
OR
SELECT ID FROM wp_posts WHERE post_type = "page" AND
post_status="publish" AND post_content LIKE '%[registration id="17"]%'
答案 1 :(得分:0)
试试这个
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"]%';