mysql/ target=_blank class=infotextkey>mysql数据库统计多表交叉组合总数
例子:
>mysql -h localhost -u root -p
mysql> use world;
Database changed
mysql> show tables;
+-----------------+
| Tables_in_world |
+-----------------+
| city |
| country |
| countrylanguage |
+-----------------+
3 rows in set (0.00 sec)
mysql> select count(*) from city;
+----------+
| count(*) |
+----------+
| 4079 |
+----------+
1 row in set (0.00 sec)
mysql> select count(*) from country;
+----------+
| count(*) |
+----------+
| 239 |
+----------+
1 row in set (0.00 sec)
mysql> select 4079*239
-> ;
+----------+
| 4079*239 |
+----------+
| 974881 |
+----------+
1 row in set (0.00 sec)
这里就是计算交叉组合数量,(www.jb200.com)因为它们之间一个相同的关联字段。
实际上mysql所做的操作就是把你所查询表的数量相乘得到的结果!