I ran into a strange thing that I was not expecting today.
I am trying to query from a database table and order by a column. This is not normally a big deal. The column (names "TLD") on which I am sorting is an ENUM and is defined like this:
enum('com', 'net', 'org', 'us', 'info', 'biz')
The select statement I have looks like your garden variety select statement:
$sql = "SELECT * from DOMAINS order by TLD asc";
I expected the results to be given to me in this order:
biz
com
info
net
org
us
This is not the case. The results are displayed in the order that they appear in the enumeration. In other words, they display in this order:
com
net
org
us
info
biz
Other than the obvious solution of putting the values in the enumeration in the correct order - Is there a way to sort the rows in the enumerated column alphabetically instead of the way that they appear in the enumeration?
-Bob
I am trying to query from a database table and order by a column. This is not normally a big deal. The column (names "TLD") on which I am sorting is an ENUM and is defined like this:
enum('com', 'net', 'org', 'us', 'info', 'biz')
The select statement I have looks like your garden variety select statement:
$sql = "SELECT * from DOMAINS order by TLD asc";
I expected the results to be given to me in this order:
biz
com
info
net
org
us
This is not the case. The results are displayed in the order that they appear in the enumeration. In other words, they display in this order:
com
net
org
us
info
biz
Other than the obvious solution of putting the values in the enumeration in the correct order - Is there a way to sort the rows in the enumerated column alphabetically instead of the way that they appear in the enumeration?
-Bob






