Mysql query - problem with order by
Posted
by Sergio
on Stack Overflow
See other posts from Stack Overflow
or by Sergio
Published on 2010-03-12T22:34:25Z
Indexed on
2010/03/12
22:37 UTC
Read the original article
Hit count: 255
I'm using two tables for selecting messages between users. Table "messages" for recording the messages and table "members" for checking users data (are they activ or deleted).
This query working fine.
What I need to do is list the received messsages order by last received. I tried to do with "ORDER BY messages.id DESC" at the end of this query but it didn't work. All messages are listed from first received.
This is the mysql join table query that I'm using:
sql = "select distinct messages.fromid, messages.readed, messages.fromid,
messages.toid, members.id as pid From messages
Inner Join members on members.id = messages.fromid Where messages.toid = ".$mid."
AND members.status = 7 AND messages.kreaded !='1' AND messages.subject != 'readed'
GROUP BY fromid"
Is there any way to do this?
© Stack Overflow or respective owner