Re:Selecting 3 highest values froma table (1 viewing) (1) Guests
Selecting 3 highest values froma table
by jahflasher 6 Months, 3 Weeks ago
I know how to select the max value from a table but i am now trying to select the three highest values from a table. Exactly how is that done?
The administrator has disabled public write access. | Report to moderator   Logged Logged  
Re:Selecting 3 highest values froma table
by cyberpunk 6 Months, 3 Weeks ago
this should be really simple.
where tablename is the name of the table and value is the field you wish to grab the highest value you for. This would solve your problem

Code: :

 select from tablename order by value DESC limit 03




Let me know if there are any problems
Last Edit: 01/31/2008 06:50pm By cyberpunk.
The administrator has disabled public write access. | Report to moderator   Logged Logged  
Re:Selecting 3 highest values froma table
by jahflasher 6 Months, 3 Weeks ago
Hey thanks. I appreciate your response.
The administrator has disabled public write access. | Report to moderator   Logged Logged  
Re:Selecting 3 highest values froma table
by cyberpunk 6 Months, 3 Weeks ago
okay. did it work? Thats whats really important to me. Lemme know if the things work.
The administrator has disabled public write access. | Report to moderator   Logged Logged  
Re:Selecting 3 highest values froma table
by jahflasher 6 Months, 3 Weeks ago
ok. i tried it :

SELECT * FROM `myp_products_prd` ORDER BY 'price_pdt' DEC LIMIT 0,3

but this is what i am getting:

"#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEC LIMIT 0,3' at line 1"
The administrator has disabled public write access. | Report to moderator   Logged Logged  
Re:Selecting 3 highest values froma table
by cyberpunk 6 Months, 3 Weeks ago
try "DESC".. mistake on my part.
The administrator has disabled public write access. | Report to moderator   Logged Logged  
Re:Selecting 3 highest values froma table
by jahflasher 6 Months, 3 Weeks ago
Thanks it works perfectly.
The administrator has disabled public write access. | Report to moderator   Logged Logged  
 
     
Powered by FireBoardget the latest posts directly to your desktop