2015-10-14 31 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

接受的答案在我回答後進行編輯 –