We've got it backwards:
PHP Code:
// CORRECT
SELECT * FROM `blog_posts` WHERE `post_sections` IN ('0')
// INCORRECT
SELECT * FROM `blog_posts` WHERE 0 IN (`post_sections`)
however, I think what you actually want is a LIKE statement:
PHP Code:
SELECT * FROM `blog_posts` WHERE `post_sections` LIKE '%0%'
(see example here)
Edit:
of course, that will return " 10
" and " 105
" as well as " 0
".
As you can see in my example, '%h%'
returns all the "home" rows but also an extra one - that row has a "parent" value of "archive".
maybe redesign your post_sections fields to start and end with a comma as well, like so: ,0,1,2,3,4,
then you could write your statement like this:
PHP Code:
SELECT * FROM `blog_posts` WHERE `post_sections` LIKE '%,0,%'
and get only rows with " 0
"
Bookmarks