Jump to content

Select Highest Value


andz

Recommended Posts

I have stumbled on a problem with regards to selecting the highest value from a table.

 

I have this data on my table::

 

price

1,000,000.00

3,000,000.00

500.00

23.00

5,234,234.53

 

I used SELECT * FROM `table_name` ORDER BY `price` DESC;

 

but instead of returning the highest value, that's not what happened.

 

price field is varchar(20)

 

any possible query codes would be accepted.

 

thank you.

Link to comment
https://forums.phpfreaks.com/topic/136794-select-highest-value/
Share on other sites

instead of making the field named price varchar(20) you should make it decimal(18,2) in that case it will work using the DESC function.

 

in decimal(18,2) the 2 represents how many spaces from the right the decimal will be placed from. And 18 represents how many digits come left of the decimal point. hope this helps.

Link to comment
https://forums.phpfreaks.com/topic/136794-select-highest-value/#findComment-714618
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.