From: Martijn Tonies Date: April 28 2008 1:22pm Subject: Re: get all my newest messages List-Archive: http://lists.mysql.com/mysql/212556 Message-Id: <01a601c8a932$d7668be0$9902a8c0@martijnws> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit > On 28/04/2008, Martijn Tonies 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