SELECT `c` . * , `p` . `name` AS `project_name` FROM `mantis_category_table` `c` LEFT JOIN `mantis_project_table` `p` ON `c` . `project_id` = `p` . `id` WHERE `project_id` IN (...) ORDER BY `c` . `name` 