(3).union
union中的第二个或后面的select语句.例如
mysql> explain select * from t3 where id=3952602 union all select * from t3 ; +—-+————–+————+——-+——————-+———+———+——-+——+——-+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +—-+————–+————+——-+——————-+———+———+——-+——+——-+ | 1 | PRIMARY | t3 | const | PRIMARY,idx_t3_id | PRIMARY | 4 | const | 1 | | | 2 | union | t3 | ALL | NULL | NULL | NULL | NULL | 1000 | | |NULL | union RESULT | | ALL | NULL | NULL | NULL | NULL | NULL | | +—-+————–+————+——-+——————-+———+———+——-+——+——-+ |
(4).DEPENDENT union
union中的第二个或后面的select语句,取决于外面的查询
mysql> explain select * from t3 where id in (select id from t3 where id=3952602 union all select id from t3) ; +—-+——————–+————+——–+——————-+———+———+——-+——+————————–+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +—-+——————–+————+——–+——————-+———+———+——-+——+————————–+ | 1 | PRIMARY | t3 | ALL | NULL | NULL | NULL | NULL | 1000 | Using where | | 2 | DEPENDENT SUBQUERY | t3 | const | PRIMARY,idx_t3_id | PRIMARY | 4 | const | 1 | Using index | | 3 | DEPENDENT union | t3 | eq_ref | PRIMARY,idx_t3_id | PRIMARY | 4 | func | 1 | Using where; Using index | |NULL | union RESULT | | ALL | NULL | NULL | NULL | NULL | NULL | | +—-+——————–+————+——–+——————-+———+———+——-+——+————————–+ |
(5).union RESULT
union的结果。
mysql> explain select * from t3 where id=3952602 union all select * from t3 ; +—-+————–+————+——-+——————-+———+———+——-+——+——-+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +—-+————–+————+——-+——————-+———+———+——-+——+——-+ | 1 | PRIMARY | t3 | const | PRIMARY,idx_t3_id | PRIMARY | 4 | const | 1 | | | 2 | union | t3 | ALL | NULL | NULL | NULL | NULL | 1000 | | |NULL | union RESULT | | ALL | NULL | NULL | NULL | NULL | NULL | | +—-+————–+————+——-+——————-+———+———+——-+——+——-+ |
(6).SUBQUERY
子查询中的第一个select.
mysql> explain select * from t3 where id = (select id from t3 where id=3952602 ) ; +—-+————-+——-+——-+——————-+———+———+——-+——+————-+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +—-+————-+——-+——-+——————-+———+———+——-+——+————-+ | 1 | PRIMARY | t3 | const | PRIMARY,idx_t3_id | PRIMARY | 4 | const | 1 | | | 2 | SUBQUERY | t3 | const | PRIMARY,idx_t3_id | PRIMARY | 4 | | 1 | Using index | +—-+————-+——-+——-+——————-+———+———+——-+——+————-+ |
我们一直都在努力坚持原创.......请不要一声不吭,就悄悄拿走。
我原创,你原创,我们的内容世界才会更加精彩!
【所有原创内容版权均属TechTarget,欢迎大家转发分享。但未经授权,严禁任何媒体(平面媒体、网络媒体、自媒体等)以及微信公众号复制、转载、摘编或以其他方式进行使用。】
微信公众号

TechTarget
官方微博

TechTarget中国
作者
相关推荐
-
2017年3月数据库流行度排行榜 Oracle卫冕之路困难重重
时隔一个月,数据库市场经过一轮“洗牌”,旧的市场格局是否会被打破,曾经占巨大市场份额的企业是否可能失去优势?
-
2017年2月数据库流行度排行榜 攻城容易守城难
2016年下半年,数据库排行榜的前二十名似乎都“固守阵地”,在排名上没有太大的变动。随着2017年的悄然而至,数据库的排名情况是否会有新的看点?
-
MySQL管理特性:让企业适合交易平台
当Alexander Culiniac和他的同事在TickTrade系统公司建立一个基于云的交易平台时,面临一些基本的约束。那就是,系统必须在云上工作良好并且经济实用。
-
数据库和数据仓库的区别在哪儿?
目前,大部分数据仓库还是用数据库进行管理。数据库是整个数据仓库环境的核心,是数据存放的地方和提供对数据检索的支持。