On Friday 17 August 2001 10:05, Fabian Groene wrote:
> Hi,
>
> >The usual solution would be a subselect a la:
> >
> >  select gname, item, gdate
> >    from groups
> >   where gdate in (select max(gdate)
> >                  from groups
> >                 group by gname)
> >
> >Alas no subselects yet in MySQL (see:
> > http://www.mysql.com/doc/M/i/Missing_Sub-selects.html )
>
> I tried this subquery with an ODBC database that I queried with SQL
> commands. It does not work properly because there were groups of which two
> or more items were shown. That should be avoided ;-(

That's because 'gdate' is being used as the key in this example (health 
warning: simplified example, use at own risk ;-). So any group record with 
the same date as the most recent date of another group record will 
automatically be selected too. Really every record should have a unique key 
to avoid this.

HTH


Ian Barwick

-- 
Ian Barwick - Developer - [EMAIL PROTECTED]
akademie.de asp GmbH - http://www.akademie.de

"To query tables in a MySQL database is more fun than eating spam"

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to