求几条同结构多表查询的SQL语句 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 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你的版本要是支持嵌套的话第一个就很简单了,不支持有点麻烦,第二个可以这样吧:select * from a1 limit 5 union all select * from a2 limit 10; 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、楼上那位的就非常简明了! 这样还是不错,就是不是按照你的格式mysql> select count(*) from send -> union all -> select count(*) from sendlog;+----------+| count(*) |+----------+| 10 || 122259 |+----------+2 rows in set (17.34 sec) mysql 错误1064 关于mysql中MYD文件的大小问题 想写个mysql的批处理文件帮看看怎么写 怎样将xls导入到mysql 【急问】怎么备份和恢复mysql数据库?在php里面可以做吗? MySQL导入数据问题 mysql语句的高级应用,难 如何连接数据库? 用tomcat5.0,使用哪个版本的mysql比较好 远程数据库与远程表的区别 高手们。快来了。这种SQL怎么实际呢? mysql 中表与表之间关联问题及优化!在线等待。
select * from a1 limit 5 union all select * from a2 limit 10;
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、楼上那位的就非常简明了!
-> union all
-> select count(*) from sendlog;
+----------+
| count(*) |
+----------+
| 10 |
| 122259 |
+----------+
2 rows in set (17.34 sec)