Mysql : Request to select the last 10 send/received messages to/by different users
        Posted  
        
            by Yako malin
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Yako malin
        
        
        
        Published on 2010-04-29T06:59:56Z
        Indexed on 
            2010/04/29
            7:07 UTC
        
        
        Read the original article
        Hit count: 560
        
Hello,
I want to select the 10 last messages you received OR you sent TO different users.
For example the results must be shown like that : 
1. John1 - last message received 04/17/10 3:12 
2. Thomy - last message sent 04/16/10 1:26 
3. Pamela - last message received 04/12/10 3:51 
4. Freddy - last message received 03/28/10 9:00 
5. Jack - last message sent 03/20/10 4:53 
6. Tom - last message received 02/01/10 7:41 
..... 
Table looks like :
CREATE TABLE `messages` ( 
`id` int(11) NOT NULL AUTO_INCREMENT, 
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 
`sender` int(11) DEFAULT NULL, 
`receiver` int(11) DEFAULT NULL, 
`content` text 
) 
Have someone any solution ? Thanks in advance for your help.
© Stack Overflow or respective owner