请问有一下有没有办法解决这个sql问题啊?我用的是mysql数据库
因为表的字段比较多,所以想用*号全部查询出来,然后再自己定义一个比例字段如下,然后按照这个新字段降序排列显示,但是提示错误,请教大家如何修改啊?select *,(click/showCount) as cs from taoke_taoke where (fid in(11,6,7,8,9,10,1,2,3)) order by cs desc
查询错误
Unknown column 'cs' in 'order clause'

解决方案 »

  1.   

    我在自己的数据库里试了一下,ok的我用的是MySQL 5的
      

  2.   

    如楼上,测试没有问题。
    mysql> select *,col2+1 as cs from t2 where id < 10 order by cs;
    +----+------+------+------+------+
    | id | gid  | col1 | col2 | cs   |
    +----+------+------+------+------+
    |  1 | A    |   31 |    6 |    7 |
    |  5 | E    |    3 |   17 |   18 |
    |  3 | C    |   76 |   21 |   22 |
    |  8 | C    |   16 |   22 |   23 |
    |  9 | D    |   25 |   43 |   44 |
    |  4 | D    |   63 |   56 |   57 |
    |  7 | B    |   88 |   63 |   64 |
    |  2 | B    |   25 |   83 |   84 |
    |  6 | A    |   29 |   97 |   98 |
    +----+------+------+------+------+
    9 rows in set (0.05 sec)mysql> select version();
    +----------------------+
    | version()            |
    +----------------------+
    | 5.1.33-community-log |
    +----------------------+
    1 row in set (0.05 sec)mysql>