I have messages from user id 1(5), 2(1), 3(1). (parenthesis show the number of messages for each user id)
Hi here is my code:
$stmt = $dbh->prepare("SELECT * FROM messages WHERE user_id = :user_id ORDER BY id DESC");
i have messages for user id 1, 2, and 3. but for users that have multiple messages like user id 1, I want to only select the latest message from user id 1 and NOT all five messages and i want to select the latest messages from user id 2 and 3. how can i do that? thanks.