SELECT DISTINCT (co_style.style_name), co_style.style_id FROM co_data, co_style WHERE co_presenter_id = and co_data.co_style_id = co_style.style_id ORDER BY co_style.style_name 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 co_data.co_style_id = co_style.style_id ORDER BY co_style.style_name' at line 4