博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mysql 连接查询 和 子查询
阅读量:7049 次
发布时间:2019-06-28

本文共 1675 字,大约阅读时间需要 5 分钟。

子查询形式的执行计划

mysql> explain select * from user where id = (select uid from uu where id = 3)\G *************************** 1. row ***************************            id: 1   select_type: PRIMARY table: user          type: const possible_keys: PRIMARY key: PRIMARY       key_len: 4           ref: const          rows: 1         Extra: *************************** 2. row ***************************            id: 2   select_type: SUBQUERY table: uu          type: const possible_keys: PRIMARY key: PRIMARY       key_len: 4           ref:          rows: 1         Extra: 2 rows in set (0.00 sec)

子查询的结果

mysql> select * from user where id = (select uid from uu where id = 3); +----+------+------+ | id | name | age  | +----+------+------+ |  9 | qw13 |   18 | +----+------+------+

连接查询的执行计划

mysql> explain select * from user left join uu on user.id = uu.uid where uu.id=3  \G *************************** 1. row ***************************            id: 1   select_type: SIMPLE table: uu          type: const possible_keys: PRIMARY,uid key: PRIMARY       key_len: 4           ref: const          rows: 1         Extra: *************************** 2. row ***************************            id: 1   select_type: SIMPLE table: user          type: const possible_keys: PRIMARY key: PRIMARY       key_len: 4           ref: const          rows: 1         Extra: 2 rows in set (0.02 sec)

链接查询的结果

mysql> select * from user left join uu on user.id = uu.uid where uu.id=3; +----+------+------+----+------+-------+ | id | name | age  | id | uid  | other | +----+------+------+----+------+-------+ |  9 | qw13 |   18 |  3 |    9 | asd   | +----+------+------+----+------+-------+

未完待续……

转载地址:http://tipol.baihongyu.com/

你可能感兴趣的文章
HanzFontMaker--支持所有字体的点阵取模软件
查看>>
IDEA常用快揵键
查看>>
git 学习笔记
查看>>
[HDU5528]Count a * b
查看>>
[HDU5968]异或密码
查看>>
Vue的安装
查看>>
iOS开发~CocoaPods使用详细说明
查看>>
书城项目第五阶段---book表的curd
查看>>
分割字符串
查看>>
图形绘制管线
查看>>
C#扩展方法
查看>>
资源记录
查看>>
逆置单链表
查看>>
33 ArcToolBox学习系列之数据管理工具箱——投影与变换(Projections and Transformations)未完待续……...
查看>>
iOS 9 的新功能 universal links
查看>>
内容滚动条 案例
查看>>
移动浏览器中实现拨打电话,调用sms,发送email
查看>>
docker 搭建小型的node开发环境。
查看>>
angular和vue的对比学习之路
查看>>
Java第九次作业
查看>>