Take single request per member

SELECT `members_requests`.`id`, `members_requests`.`name`, `cadres`.`name` AS `cadre_name_en`, `designation`, `phone`, `members_requests`.`member_id`, `members_requests`.`created_at` FROM `members_requests` LEFT JOIN `cadres` ON `cadres`.`id` = `members_requests`.`cadre_id` INNER JOIN (SELECT member_id, max(created_at) AS last_date FROM members_requests GROUP BY member_id) AS sp2 ON `sp2`.`member_id` = `members_requests`.`member_id` AND `sp2`.`last_date` = `members_requests`.`created_at` WHERE `status` = ? ORDER BY `created_at` DESC;

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.