Re: How to select the max value

2005-04-13 Thread Mauricio Pellegrini
Yes, I'm using 4.1.x and didn't think of doing the query that way. You have been extremely helpfull Thanks! On Tue, 2005-04-12 at 21:44, Rhino wrote: > What version of MySQL are you using? > > If you are running 4.1.x or 5.0.x, you should be able to do this subquery to > get the row you want. >

Re: How to select the max value

2005-04-12 Thread Daniel Kasak
Daniel Kasak wrote: >Mauricio Pellegrini wrote: > > > >>Hi, >>I need to select the max value from a set of records but I also need the >>primary key for that record. >> >>The problem is that the record id may not be the same as the record max >>value for the column as in the following example: >

Re: How to select the max value

2005-04-12 Thread Rhino
What version of MySQL are you using? If you are running 4.1.x or 5.0.x, you should be able to do this subquery to get the row you want. select id, col_x, date_col from table_x where date_col = (select max date_col from table_x) The subquery gets the max (latest) date in the table, then t

Re: How to select the max value

2005-04-12 Thread Daniel Kasak
Mauricio Pellegrini wrote: >Hi, >I need to select the max value from a set of records but I also need the >primary key for that record. > >The problem is that the record id may not be the same as the record max >value for the column as in the following example: > >Table_x > >Id x_col date_co