select (SELECT COUNT(1) from a1) as a1 ,(SELECT COUNT(1) from a2) as a2,(SELECT COUNT(1) from a3) as a3,(SELECT COUNT(1) from a4) as a4

解决方案 »

  1.   

    你的版本要是支持嵌套的话第一个就很简单了,不支持有点麻烦,第二个可以这样吧:
    select * from a1 limit 5 union all select * from a2 limit 10;
      

  2.   

    1、不支持子查询可以用变量或临时表,如:mysql> set @index1:=0;
    Query OK, 0 rows affected (0.00 sec)mysql> select @index1:=count(*) from send;
    +-------------------+
    | @index1:=count(*) |
    +-------------------+
    |                10 |
    +-------------------+
    1 row in set (0.02 sec)mysql> set @index2:=0;
    Query OK, 0 rows affected (0.00 sec)mysql> select @index2:=count(*) from sendlog;
    +-------------------+
    | @index2:=count(*) |
    +-------------------+
    |            122259 |
    +-------------------+
    1 row in set (3.22 sec)mysql> select @index1 as num1,@index2 as num2;
    +------+--------+
    | num1 | num2   |
    +------+--------+
    |   10 | 122259 |
    +------+--------+
    1 row in set (0.01 sec)
    2、楼上那位的就非常简明了!
      

  3.   

    这样还是不错,就是不是按照你的格式mysql> select count(*) from send
        -> union all
        -> select count(*) from sendlog;
    +----------+
    | count(*) |
    +----------+
    |       10 |
    |   122259 |
    +----------+
    2 rows in set (17.34 sec)