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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -