DanDaBeginner Posted February 27, 2007 Share Posted February 27, 2007 I have this: table name: message Fields: message_id | recepient_id | sender_id | content | time_sent | read auto+increment 1 2 hello! 2 1 hi! 1 3 kiss me! 3 1 sure! ----------------------------------- now my question is how can I get the latest conversation between 2 and 1.. for example 1 is the user and if 1 is the latest sender of their conversation it will display like this: Message: welcome 1. conversation with 2: hello! - by me if 2 is the lates of their sender then it will display like this: Message: welcome 1. conversation with 2: hi! Quote Link to comment Share on other sites More sharing options...
btherl Posted February 27, 2007 Share Posted February 27, 2007 How about: SELECT * FROM message WHERE recipient_id IN (1, 2) ORDER BY message_id DESC LIMIT 1 Or, order by time_sent, which should match message_id in ordering I presume. Then you can check if the message was to 1 or 2 and display the appropriate output. Is that what you wanted? Quote Link to comment Share on other sites More sharing options...
DanDaBeginner Posted February 27, 2007 Author Share Posted February 27, 2007 not exactly but you gave a very good idea.. thanx.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.