RE: [PHP] getting only the largest or smallest values in a select statement
| From: | richard | Date: | Fri, 06 Oct 2000 23:26:58 +0000 |
| Subject: | RE: [PHP] getting only the largest or smallest values in a select statement | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-19000@lists.php.net to get a copy of this message | ||
create the SQL statement with a sort on the field you want, and put "LIMIT
1" on the end of the statement
this will return you only one value, and the sort direction will determin if
its the largest or smallest...
richard
-----Original Message-----
From: Dave Gardner [mailto:dgardner@exactax.com]
Sent: Friday, October 06, 2000 4:07 PM
To: mysql@lists.mysql.com; php-general@lists.php.net
Subject: [PHP] getting only the largest or smallest values in a select
statement
How can I get the largest (or smallest) value of a column in multiple
records, culled from a select statement? Let's say I did a 'select id,
amount from purchases' and got the following:
id amount
-- -------
1 488
2 1256
3 188
4 97
5 166
Is it possible to modify the query itself to select only the largest or
smallest value in 'amount' as displayed here? Or is there something I need
to do in PHP to figure that out?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net