If you only want to get the Max or min of a single row, then you should try something like: SELECT date_value, version_id FROM dates WHERE version_id=2 ORDER BY date_value DESC LIMIT 1;
However if there might be two of the rows with the highest you will need to use either a max-concat trick or table locking to accomplish this in MySQL. This is detailed at: www.mysql.com/doc/e/x/example-Maximum-column-group-row.html Hope that helps some. Harrison ----- Original Message ----- From: "support" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, May 06, 2002 12:25 AM Subject: SQL-query > Hello, > > A real SQL-query works well > SELECT MAX(date_value) AS date_value FROM dates WHERE version_id='2' > > But the problem is, that I can't get a value of another column, i.e. > > the row in a table consists of three columns - id, date_value and > version_id > > The task - to get a value of id column where date_value is the biggest > while version_id is preset > > Thank you > > > > > > --------------------------------------------------------------------- > 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 > > > --------------------------------------------------------------------- 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