SQL
$sql = "SELECT DISTINCT from_user, messages.* FROM messages WHERE to_user = :user OR from_user = :usr Group BY from_user
ORDER BY time DESC";
It works but It shows user message from latter
, before order by How I could do something like
$sql = "SELECT DISTINCT from_user, messages.* FROM messages WHERE to_user = :user OR from_user = :usr Group BY from_user HAVING time ASC
ORDER BY time DESC";
?
HAVING time ASC ORDER BY time DESC"; ?
I think you guys got me now , how to solve ?
my table structure
I need to select
last message from each user by time ASC
and than latter order
by time DESC
I tried with
$sql = "SELECT DISTINCT from_user, messages.* FROM messages WHERE to_user = :user OR from_user = :usr ORDER BY time ASC Group BY from_user
ORDER BY time DESC";
but do not worked