Mysql查询帮助

时间:2011-09-11 00:10:47

标签: mysql sql wordpress

我有一个表格wp_posts,列 post_content 。一些帖子条目在post_content列中有 [nggallery id = x] 。我想在post_content列中查找所有帖子以及x(图库ID号,不同图库不同)升序,其中 nggallery id 。我该怎么办?

3 个答案:

答案 0 :(得分:1)

您可以尝试这样的事情:

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

答案 1 :(得分: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

答案 2 :(得分:0)

也许他的意思是:

SELECT * FROM wp_posts WHERE post_content LIKE“[nggallery id =%]”

MySQL字符串比较函数:http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html