我正在尝试分组并按顺序一起工作,但没有运气可能有人告诉我我做错了什么。
$get1_msg1 = mysqli_query($con, "select * from (select message_id, sender, receiver, message, read_status, time_sent from user_messages where receiver='".$_SESSION['userid']."' order by time_sent desc ) as temp group by sender order by time_sent desc ");
我不确定我做错了什么。
答案 0 :(得分:0)
根据您的评论,您可以尝试
"select message_id, sender, receiver, message, read_status, time_sent
from user_messages where message_id in (
select message_id
from user_messages
where (sender, time_sent) in (
select sender, max(time_sent )
from user_messages
where receiver='".$_SESSION['userid']."'
group by sender
)
)
and receiver='".$_SESSION['userid']."'";