Query SELECT ua.id blog_author_id, ua.username blog_author, ub.id blog_id, ub.title blog_title, ub.about blog_about, ub.goog_analytics_key blog_stats_key, ub.num_on_homepage, ub.custom_css, bp.*, bp.id blog_post_id, bp.text_id blog_post_text_id, bt.filename template_filename FROM user_accounts ua INNER JOIN user_blogs ub ON ub.user_id = ua.id INNER JOIN blog_posts bp ON ub.id = bp.blog_id INNER JOIN blog_templates bt ON ub.blog_template_id = bt.id WHERE ua.username = 'Thorax O'Tool' AND bp.text_id = 'chalk-off-prize-this-friday' failed with error 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 'Tool' AND bp.text_id = 'chalk-off-prize-this-friday'' at line 10