如:
select count(*) as total,(total +1 ) as total2
这是个错误的例子,请问如何才能实现我所需要的功能?

解决方案 »

  1.   

    select count(*) as total ,count(*)+1 as total2 from table_name
      

  2.   

    很明显二楼的错误的。第二个字段total 从那里来?mysql> select (total + 1) as total2 from (select count(*) as total) as t;
    +--------+
    | total2 |
    +--------+
    |      2 |
    +--------+
    1 row in set (0.03 sec)
      

  3.   

    LZ给的没有表,只是这个SELECT语句的正确与否。
      

  4.   


    select count(*) as total ,count(*)+1 as total2 from table_name而且你这句也是不能成功 的
      

  5.   

    没有给表的话,count(*) 有用吗??这是我的一个测试:
    mysql> select count(*) as total ,count(*)+1 as total2 from town;
    +-------+--------+
    | total | total2 |
    +-------+--------+
    |    35 |     36 | 
    +-------+--------+
    1 row in set (0.00 sec)