Enhancing an 'ORDER BY' clause to judge condition by more than 1 integer

Posted by Yvonne on Stack Overflow See other posts from Stack Overflow or by Yvonne
Published on 2010-04-05T19:46:37Z Indexed on 2010/04/05 19:53 UTC
Read the original article Hit count: 249

Filed under:
|
|
|

Hi folks,

I have some PHP code which allows me to sort a column into ascending and descending order (upon click of a table row title), which is good. It works perfectly for my D.O.B colum (with date/time field type), but not for a quantity column.

For example, I have quantites of 10, 50, 100, 30 and another 100.

The order seems to be only appreciating the 1st integer, so my sorting of the column ends up in this order: 10, 100, 100, 30, 50... and 50, 30, 100, 100, 10.

This is obviously incorrect as 100 is bigger than 50, therefore both 100 values should appear at the end surely? It seems to me that 100 is only being taken into account as having the '1' value, then it appears before 10 because the system recognises it has another 0.

Is this normal to happen? Is there any way I can solve this problem? Thanks for any help. P.S. I can show code if necessary, but would like to know if this is a common issue by default.

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql