2011-09-11 259 views
0

我有一個表wp_posts與列post_content。一些帖子條目在post_content列中有[nggallery id = x]。我想找到所有帖子以及x(gallery id no,它不同於不同的圖庫),在post_content列中有nggallery id。我該怎麼辦?Mysql查詢幫助

+2

當在這裏發佈SQL問題時(以及更好的一些示例數據以及迄今爲止您嘗試過的查詢無法正常工作),您應該始終發佈您的表模式。 – jadarnel27

+0

這是很難忍受你的問題。 – user482594

回答

1

你可以嘗試這樣的:

SELECT * FROM wp_posts WHERE post_content LIKE '%[nggallery id=%'; 
1

試試這個,只是不問:)

select 
left(substring(post_content,locate('[nggallery id=',post_content)+14,5),locate(']',substring(post_content,locate('[nggallery id=',post_content)+14,5))-1) as NumValue, post_content 
from wp_posts 
WHERE post_content LIKE "[nggallery id=%]" 
ORDER BY 1