Invalid query: 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 'as projecttopic, project_pages.visible as projectvisible FROM project_pages LEFT' at line 1 Whole query: SELECT *, project_pages. as projecttopic, project_pages.visible as projectvisible FROM project_pages LEFT JOIN people_pages ON project_pages.id = people_pages.id ORDER BY project_pages. DESC, client_name ASC