MySQL multiple group by using -
now using query :
select * messages receiverid='$uid' or senderid='$uid' group recei verid,senderid order datex desc
but results
id receiverid senderid 1 2 1 2 1 2
but want showing 1 result syntax. example:
id receiverid senderid 1 2 1
or
id receiverid senderid 2 1 2
you want use least()
, greatest()
:
select * messages receiverid='$uid' or senderid='$uid' group least(receiverid, senderid), greatest(receiverid, senderid) order datex desc;
however, should list columns explicitly in select
. using mysql extension have columns in select
not in group by
. bad idea unless understand doing.
Comments
Post a Comment