2015-10-14 45 views
0

我想找出具有短代码的页面ID。这是我想在MySQL phpmyadmin在phpmyadmin中显示错误的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"]%" 

LIMIT 0,25' 列提前1个

感谢。

+0

'ID ='17''而不是'ID = “17”' – asprin

回答

3

你在你的SQL

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']%" 

如果你真的想匹配 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"]%' 
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"]%'; 
+0

如何这与接受的答案有什么不同? – asprin

+0

接受的答案在我回答后进行编辑 –