t * from table_name order by movid desc limit 1
>
>
>
>
>
>
> From: Roland Kaber
> To: armando
> Cc: tech list ; mysql@lists.mysql.com
> Sent: Sat, 6 February, 2010 8:28:06 PM
> Subject: Re: max() can't work
>
> The max() function
:28:06 PM
Subject: Re: max() can't work
The max() function is an aggregate function which can be used in
conjunction with GROUP BY in the SELECT or HAVING clause:
http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html . This
code should work:
select * from table_name group by
Yes - you must use the subselect. Or, you can set a variable like:
select @max := max(movid) from table_name;
select * from table_name where movid = @max;
On Sat, Feb 6, 2010 at 8:34 AM, tech list wrote:
> select * from table_name where movid = max(movid);
>
> why the sql above can't work?
>
The max() function is an aggregate function which can be used in
conjunction with GROUP BY in the SELECT or HAVING clause:
http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html . This
code should work:
select * from table_name group by movid having max(movid).
However, there is a simp
the field "movid" is type integer or varchar ?
2010/2/6 tech list
> select * from table_name where movid = max(movid);
>
> why the sql above can't work?
> Shall I use a sub-select instead?
>
> select * from table_name where movid = (select max(movid) from table_name)
> ?
>
>
> Thanks in advance