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! Link to comment https://forums.phpfreaks.com/topic/40324-need-advisehelp-with-my-query/ 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? Link to comment https://forums.phpfreaks.com/topic/40324-need-advisehelp-with-my-query/#findComment-195091 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.. Link to comment https://forums.phpfreaks.com/topic/40324-need-advisehelp-with-my-query/#findComment-195110 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.