D
Dylan Parry
Hi folks,
I have a database that contains records with IDs like "H1, H2, H3, ...,
Hn" and these refer to local government policy numbers. For example, H1
might be "Housing Policy 1" and so on. For some more insight, not all
policies will be prefixed with an "H", an in fact they could be prefixed
with *any* letter combination, but they will always end with a number.
When I retrieve them from the database I use "ORDER BY id" to get them
into a sensible order, but obviously as the IDs are strings I get them
returned like "H1, H10, H11, H2, ...". Alphabetically this is fine, but
logically (to a human at least) this order makes no sense whatsoever.
So what I'm looking for is either a way of changing the order in SQL to
something more sensible like "H1, H2, H3, ..., H10, H11" or a method of
sorting the results array *after* it has been returned from my SQL
query.
Any ideas?
I have a database that contains records with IDs like "H1, H2, H3, ...,
Hn" and these refer to local government policy numbers. For example, H1
might be "Housing Policy 1" and so on. For some more insight, not all
policies will be prefixed with an "H", an in fact they could be prefixed
with *any* letter combination, but they will always end with a number.
When I retrieve them from the database I use "ORDER BY id" to get them
into a sensible order, but obviously as the IDs are strings I get them
returned like "H1, H10, H11, H2, ...". Alphabetically this is fine, but
logically (to a human at least) this order makes no sense whatsoever.
So what I'm looking for is either a way of changing the order in SQL to
something more sensible like "H1, H2, H3, ..., H10, H11" or a method of
sorting the results array *after* it has been returned from my SQL
query.
Any ideas?