I have this sql query:
$result = mysql_query("SELECT * FROM chat WHERE `to_id` = '$user_id' AND `from_id` IN($data)") or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
print_r($row);
}
that returns this arrays:
Array ( [id] => 3505 [from_id] => 111 [to_id] => 109 [message] =>How are you? [sent] => 1343109753 [recd] => 1 [system_message] => no )
Array ( [id] => 3506 [from_id] => 111 [to_id] => 109 [message] =>well... [sent] => 1343109759 [recd] => 1 [system_message] => no )
Array ( [id] => 3507 [from_id] => 141 [to_id] => 109 [message] => bye [sent] => 1343901524 [recd] => 1 [system_message] => no )
From_id is the user ID of the person sending the message but I would like to get only one (the most recent) result for each ‘from_id’. (in this example I got 2 messages from the same ‘from_id’ – 111)
Maybe
GROUP BY: