27, 2001 8:21 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: Select and =MAX()
Jorge
When I issue your suggested commands here are the resulted rows..
mysql> SELECT price
->FROM shop
->HAVING price=MAX(price);
Empty set (0.01 sec)
But when I issue...
mysql> sel
Jorge
When I issue your suggested commands here are the resulted rows..
mysql> SELECT price
->FROM shop
->HAVING price=MAX(price);
Empty set (0.01 sec)
But when I issue...
mysql> select price from shop order by price desc;
+---+
| price |
+---+
| 19.95 |
| 10.99 |
| 3.9
For best performance i prefer this way (it's faster):
SELECT MAX(price) FROM shop;
rather than
SELECT price FROM shop ORDER BY price DESC LIMIT 1;
--
In second case MySQL must select all records from table, sort it and then apply
LIMIT (it's must be logicaly slower than first one)
Michal D
om: bobby [mailto:bobby] On Behalf Of R Talbot
Sent: Tuesday, June 26, 2001 7:16 PM
To: [EMAIL PROTECTED]
Subject: Select and = MAX()
Following the Tutorial
Creating and populating the table Shop in the db Test..
Why won't the following syntax work?
mysql> select price
-> from shop
Why bother when the following works:
mysql> SELECT price FROM shop ORDER BY price DESC LIMIT 1;
On Tue, 26 Jun 2001, R Talbot wrote:
> Following the Tutorial
> Creating and populating the table Shop in the db Test..
> Why won't the following syntax work?
>
> mysql> select price
> ->
Following the Tutorial
Creating and populating the table Shop in the db Test..
Why won't the following syntax work?
mysql> select price
-> from shop
-> where price=Max(price) ;
ERROR : Invalid use of group function
Bob T