mysql合并统计总数,mysql统计多表交织组合总数
mysql統(tǒng)計多表交叉組合總數(shù)
>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)
這里就是計算交叉組合數(shù)量,因為他們之間一個相同的關聯(lián)字段
mysql> select count(*) from city,country
-> ;
+----------+
| count(*) |
+----------+
| 974881 |
+----------+
1 row in set (0.00 sec)
實際上mysql所做的操作就是把你所查詢表的數(shù)量相乘得到的結果!
mysql> select count(*) from city,country,countrylanguage;
+-----------+
| count(*) |
+-----------+
| 959282904 |
+-----------+
1 row in set (0.02 sec)
mysql> select count(*) from countrylanguage;
+----------+
| count(*) |
+----------+
| 984 |
+----------+
1 row in set (0.00 sec)
mysql> select 4079*239*984;
+--------------+
| 4079*239*984 |
+--------------+
| 959282904 |
+--------------+
1 row in set (0.00 sec)
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結
以上是生活随笔為你收集整理的mysql合并统计总数,mysql统计多表交织组合总数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 烧脑最囧挑战13关怎么过(有无书友看过初
- 下一篇: airpods2和1有什么区别