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 's%'' at line 1 select post_id from blog_posts where (blog_posts.post_notimportant!=1 and post_flag!=1) and post_title like 'Blog of shadow's%'