1064: 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 'ORDER BY bp.publication_date_post DESC LIMIT 0,1000000' at line 18

your query is: SELECT DISTINCT bp.publication_id, bp.publication_title, DATE_FORMAT(bp.publication_date_post,'%d') AS publication_Data, DATE_FORMAT(bp.publication_date_post,'%m') AS publication_Mon, DATE_FORMAT(bp.publication_date_post,'%Y') AS publication_Yea, RIGHT(LEFT(bp.publication_body,61),14) AS publication_image, bp.publication_image as url_image, LEFT(CONVERT(bp.publication_body USING utf8),400) AS publication_body_resumo, (SELECT btt.type_value FROM blog_type_tag btt LEFT JOIN blog_tags bt on bt.tag_value=btt.type_id WHERE bt.publication_id=bp.publication_id limit 1 ) as TAG1, (SELECT bt.tag_value FROM blog_type_tag btt LEFT JOIN blog_tags bt on bt.tag_value=btt.type_id WHERE bt.publication_id=bp.publication_id limit 1 ) as TAG1_id, (SELECT btt.type_value FROM blog_type_tag btt LEFT JOIN blog_tags bt on bt.tag_value=btt.type_id WHERE bt.publication_id=bp.publication_id limit 1,1 ) as TAG2, (SELECT bt.tag_value FROM blog_type_tag btt LEFT JOIN blog_tags bt on bt.tag_value=btt.type_id WHERE bt.publication_id=bp.publication_id limit 1,1 ) as TAG2_id, (SELECT btt.type_value FROM blog_type_tag btt LEFT JOIN blog_tags bt on bt.tag_value=btt.type_id WHERE bt.publication_id=bp.publication_id limit 2,1 ) as TAG3, (SELECT bt.tag_value FROM blog_type_tag btt LEFT JOIN blog_tags bt on bt.tag_value=btt.type_id WHERE bt.publication_id=bp.publication_id limit 2,1 ) as TAG3_id FROM blog_publication bp LEFT JOIN blog_tags bt on bt.publication_id=bp.publication_id LEFT JOIN blog_type_tag btt on btt.type_value=bt.tag_value WHERE bp.deleted='0' and bt.tag_value= ORDER BY bp.publication_date_post DESC LIMIT 0,1000000