List:General Discussion« Previous MessageNext Message »
From:Martin Ramsch Date:September 28 1999 2:41pm
Subject:Re: max = colname
View as plain text  
On Tue, 1999-09-28 16:30:11 +1000, Michael Farr wrote:
> I am trying to get the latest row from the database with 
> 
> mysql> SELECT dateMade FROM OrthodonticAnalysis HAVING max(dateMade) = dateMade;
> Empty set (0.00 sec)
> 
> The result should not be the empty set, I got it to work with this query
> 
> mysql> SELECT dateMade FROM OrthodonticAnalysis ORDER BY dateMade DESC LIMIT 1;
> +------------+
> | dateMade   |
> +------------+
> | 1999-09-28 |
> +------------+
> 1 row in set (0.00 sec)
> 
> What is wrong with the first query? 

Well, that it doesn't work for MySQL yet ...? :)

The totrial part of the MySQL Reference Manual has a little bit on the
topic, see chapters "8.3.2 The row holding the maximum of a certain
column" and "8.3.4 The rows holding the group-wise maximum of a
certain field".

Regards,
  Martin
-- 
Martin Ramsch <m.ramsch@stripped> <URL: http://home.pages.de/~ramsch/ >
PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26  E4 EC 80 58 7B 31 3A D7
Thread
max = colnameMichael Farr28 Sep
  • Re: max = colnameMartin Ramsch28 Sep