SELECT `f` . `name` , `f` . `type` , `f` . `access_level_r` , `f` . `default_value` , `s` . `value` , `s` . `text` FROM `mantis_custom_field_project_table` `p` INNER JOIN `mantis_custom_field_table` `f` ON `f` . `id` = `p` . `field_id` LEFT JOIN `mantis_custom_field_string_table` `s` ON `s` . `field_id` = `p` . `field_id` AND `s` . `bug_id` = ? WHERE `p` . `project_id` = ? ORDER BY `p` . `sequence` ASC , `f` . `name` ASC 