PDA

View Full Version : ORDER BY ASC using price??


tux
09-04-2008, 09:17 AM
Got a bit of an issue I cant figure out.

I am returning a query from a DB and need to display it by price, cheapest first.

In the DB I have 24.95, 49.95, 74.95 & 9.95.

Using ORDER BY ProdPrice ASC the values are displayed in the same way because the 9.95 has the highest first digit.

How can I get round this so that it displays 9.95, 24.95, 49.95 & 74.95

Hope this makes sense. Regards,

Paul

lux
09-04-2008, 12:36 PM
Make sure you are using the correct MySQL field type.

Change to the field type to FLOAT if you haven't already.

Then you can use ORDER BY ProdPrice [ASC,DESC]

davidj
09-04-2008, 07:03 PM
i was going to say that

tux
09-05-2008, 09:12 AM
Thanks LUX,

That work a treat after I sussed out the 'precision'. To start with it kept adding a zero to the end of each value as 'precision' was set to 3. Changed it to 2 and all was fine.

Thanks again mate, and cheers DJ.

Regards, Paul

lux
09-05-2008, 09:50 AM
Cool Tux,

also for reference if anyone needs it:

http://dev.mysql.com/doc/refman/5.0/en/data-types.html

edbr
09-05-2008, 09:55 AM
wheres Dux and his sister Effie?