MySQL - Group By using different values -
i have table of messages , below shows 3 rows - second , third being between 2 users.
when query table , use group both lines show want one.
this query:
select a.receiver order a.datetime desc limit 25;
is there way limit 1 row return when both users have been senders/receivers.
thanks
first can group larger number , group smaller one.
select a.sender, a.receiver, a.message, a. read, a.datetime messages ( a.sender = '1000000000' or a.receiver = '1000000000' ) group if(a.sender > a.receiver, a.sender, a.receiver), if(a.sender > a.receiver, a.receiver,a.sender) order a.datetime desc limit 25;
note:
the first if
picks larger number , second 1 picks smaller number.
Comments
Post a Comment