你可以在这个字段上加索引, 并且只能是 desc 或者 asccreate table test.tt(
code char(6), name varchar(10))

解决方案 »

  1.   

    create unique index ix_test_tt_code on test.tt(code desc);
      

  2.   

    /* 测试 */create table t(id int,name varchar(20));insert t select 1,'a';
    insert t select 2,'c';
    insert t select 3,'b';create index idx_t_name on t(name);select * from t;
    /*返回*/
    1 a
    2 c
    3 b
    select name from t;
    /* 返回 */
    1 a
    3 b
    2 c/* 结论 */select * from t会使用全表扫描,所以查询的顺序还是按插入的顺序,因为Mysql并没有sql server的聚集索引.select name from t会使用索引,所以返回的结果是索引的顺序,因此是有序的.
      

  3.   

    按照两位大哥说得我照做了,是对的,但如果我加上where字句,返回的那个字段就不是有序的了
      

  4.   

    那你就要加上个 order by 子句,
    这个时候(在 order by 字段上有索引)排序的速度很快.
    :)