View Single Post

   
  #6 (permalink)  
Old 04-29-2008, 08:27 PM
Martijn Tonies
 
Posts: n/a
Default Re: get all my newest messages




> On 28/04/2008, Martijn Tonies <m.tonies@upscene.com> 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
Reply With Quote