SELECT DISTINCTROW `mantis_bug_table` . * FROM `mantis_bug_table` JOIN `mantis_project_table` ON `mantis_project_table` . `id` = `mantis_bug_table` . `project_id` WHERE `mantis_project_table` . `enabled` = ? AND ( `mantis_bug_table` . `project_id` IN (...) AND `mantis_bug_table` . `view_state` = ? OR `mantis_bug_table` . `project_id` IN (...) AND `mantis_bug_table` . `view_state` != ? AND `mantis_bug_table` . `reporter_id` = ? ) AND ( `mantis_bug_table` . `status` = ? ) ORDER BY `mantis_bug_table` . `last_updated` DESC , `mantis_bug_table` . `date_submitted` DESC LIMIT ?, ... 