SELECTing a row by maximum value
| From: | Richard Fox | Date: | Mon, 30 Dec 2002 18:48:30 +0000 |
| Subject: | SELECTing a row by maximum value | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-129692@lists.php.net to get a copy of this message | ||
Hi,
What would be a query to select a single record from a number of records in
a table, depending on which one has the biggest value in an integer field?
e.g something like:
MYTABLE
------------
id ifield
1 100
2 200
3 150
SELECT * FROM MYTABLE WHERE id=$id and MAX(ifield)
should return id=2, ifield=200
(but this doesn't work, of course)
Many thanks,
Richard