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 livetime DESC LIMIT 10' at line 3SELECT stid, author, shortheadline, longheadline, storydescription, storylead, imageurl,story.imageid,from_unixtime(`livetime`,'%M %e %Y') as storydate ,from_unixtime(livetime,'%m') as storymonth,from_unixtime(livetime,'%Y') as storyyear, link1, synd_link FROM story LEFT JOIN image ON (story.imageid = image.imageid), story_x_section WHERE story.stid = story_x_section.story_id AND story_x_section.section_id = 8 and story.livetime<='1474781871' and story.livetime!='0' AND story.siteid = ORDER BY livetime DESC LIMIT 10