Possible duplicate:
Default sort-ordering in MySQL (ALTER TABLE ... ORDER BY ...;)
I have a table like this:
CREATE TABLE IF NOT EXISTS `table_test` ( `id` mediumint(8) unsigned NOT NULL, `country` enum('AF','AX','AL') DEFAULT NULL, `number` tinyint(3) unsigned DEFAULT NULL, `sort_order` double unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `country` (`country`), KEY `id` (`id`,`country`) ) ENGINE=MEMORY DEFAULT CHARSET=latin1;
I have a table for which I have changed the default order, for example:
ALTER TABLE test_table ORDER BY sort_order ASC;
This table is never updated, and no records are deleted or added during its lifetime. It all seems to work if I use the folowwing query:
SELECT * FROM test_table LIMIT 10
It returns 10 records in the correct order.
And even if I use:
SELECT * FROM test_table WHERE num=3
it returns the results in the correct order.
But if I do
SELECT * FROM test_table WHERE country='AX'
It will return the results in reverse order.
Can someone tell me how this can happen?
source share