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 'and display = 1 order by published desc limit 10' at line 3SELECT agent_blog_articles.*, agent_blog_categories.title as category, YEAR(published) as year, DAYOFMONTH(published) as day, MONTH(published) as month from agent_blog_articles JOIN agent_blog_categories on (agent_blog_articles.blog_category_id = agent_blog_categories.blog_category_id) where agent_blog_articles.site_id = and display = 1 order by published desc limit 10