Hello all,
I have a problem sorting varchar fields retrieved from a MYSQL-DB. I looked around and didn't find a solution yet, so maybe somebody here might be able to help me.
I have a field of type varchar that stores eihter integer values or a combination of int and string, something like 125-03-01 or 125A23, etc. The problem is that you never know this in advance, so sorting has to treat both types.
When I sort the data by this field, the sort order is always a kind of weird, sure because of string sorting.
Eg:
1
10
11
....
2
20
21
or
1-03
10-03
11-03
etc.
Now I'm looking for a way to let the field type as varchar, but have sorting to work correctly, doesn't matter if by SQL-statement or a PHP function.
OK, I would prefer a php function because I'm using a db-wrapper-class, and not everything is supported by the different dbms, but the most basic SQL statements.
Any help would be appreciated.
Thanks in advance
Gaucho