List:General Discussion« Previous MessageNext Message »
From:Martijn Tonies Date:April 28 2008 1:22pm
Subject:Re: get all my newest messages
View as plain text  


> On 28/04/2008, Martijn Tonies <m.tonies@stripped> wrote:
> 
> >  > 1. the newest message between myself and person A
> >  > 2. the newest message between myself and person B
> >  > 3. the newest message between myself and person C
> >  > 4. the newest message between myself and person D
> 
> > Still, define "newest":
> >
> >  - newest according to date?
> >  - newest not yet read message?
> >  - something else?
> 
> newest according to date of creation.

There are probably other solutions, but this seems to work:

select * 
from ( select * from msgs order by msgs.created desc ) t
where sender = 1 or recipient = 1
group by sender, recipient

Martijn Tonies
Database Workbench - development tool for MySQL, and more!
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com
Thread
get all my newest messagesOlav Mørkrid28 Apr
  • Re: get all my newest messagesOlav Mørkrid28 Apr
  • Re: get all my newest messagesMartijn Tonies28 Apr
  • Re: get all my newest messagesMartijn Tonies28 Apr
    • Re: get all my newest messagesOlav Mørkrid28 Apr
  • Re: get all my newest messagesMartijn Tonies28 Apr
    • Re: get all my newest messagesOlav Mørkrid28 Apr
  • Re: get all my newest messagesMartijn Tonies28 Apr
    • Re: get all my newest messagesOlav Mørkrid28 Apr