mysql:union与union all的区别
来源:互联网 发布:ubuntu ntp server 编辑:程序博客网 时间:2024/05/20 05:09
一句话总结:union all是求所有合集,不去重;union要去重,效率要比union all 低一些。
mysql> SELECT * FROM table1;
+----+------+---------------------+
| id | name | mobile |
+----+------+---------------------+
| 1 | jack | 3333,4444,5555 |
| 2 | john | 1111,2222 |
| 3 | amry | 6666,7777,8888,9999 |
+----+------+---------------------+
3 rows in set (0.00 sec)
mysql> SELECT * FROM table1 union all SELECT * FROM table1;
+----+------+---------------------+
| id | name | mobile |
+----+------+---------------------+
| 1 | jack | 3333,4444,5555 |
| 2 | john | 1111,2222 |
| 3 | amry | 6666,7777,8888,9999 |
| 1 | jack | 3333,4444,5555 |
| 2 | john | 1111,2222 |
| 3 | amry | 6666,7777,8888,9999 |
+----+------+---------------------+
6 rows in set (0.00 sec)
mysql> SELECT * FROM table1 union SELECT * FROM table1;
+----+------+---------------------+
| id | name | mobile |
+----+------+---------------------+
| 1 | jack | 3333,4444,5555 |
| 2 | john | 1111,2222 |
| 3 | amry | 6666,7777,8888,9999 |
+----+------+---------------------+
3 rows in set (0.00 sec)
mysql>
- MySQL UNION与UNION ALL的区别
- MySQL UNION与UNION ALL的区别
- mysql:union与union all的区别
- MySQL:union all与union区别详解
- MySql中UNION与UNION ALL的区别
- mysql union和union all的区别
- union 与 union all 的区别
- Union与Union All的区别
- union 与 union all的区别
- Union与Union All的区别
- Union与Union All的区别
- Union与Union All的区别
- Union 与 Union All 的区别
- oracle union 与 union all 的区别
- Union与Union All的区别
- union 与union all 的区别
- sybase union 与 union all的区别
- Union与Union All的区别
- 在realm中动态查询用户的权限&角色
- electron仿制UnrealEngine4 蓝图功能模块
- POJ 1733 Parity game——并查集 + 离散化
- 从零开始接入腾讯云智能推荐
- jetty换启动端口
- mysql:union与union all的区别
- Name node is in safe mode 解除安全模式
- 拆带13个字节帧头的264文件
- Spring bean factory
- POJ 3292 Semi-prime H-numbers
- Android6.0权限申请
- Sersync+Rsync实现触发式文件同步
- Tomcat 源码阅读(三)Catalina.start
- webservice客户端不生成JAXBElement类型