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 f.ordernumber' at line 5 SELECT f.id,f.title FROM bbs_inforums AS i LEFT JOIN forum_forums AS f ON i.forum_id = f.id WHERE i.thread_id = ORDER BY f.ordernumber