mysql的查询种类

1.simple 简单查询。查询不包含子查询和union,我们碰到的大部分查询都是简单查询。

 

 

 

执行以下sql语句:

explain select (select 1 from actor where id = 1) from
(select * from film where id = 1
union
select * from film where id = 1
) der;

会出现另外5中查询类型

#2.primary:复杂查询中最外层的 select(explain后面的第一个select)
#3.derived:包含在 from 子句中的子查询。MySQL会将结果存放在一个临时表中,也称为派生表(derived的英文含义)
#4.union:在 union 中的第二个和随后的 select,使用union关键字时,因为是临时表,所以无法使用索引,查询效率会比较低
#5.union result:从 union 临时表检索结果的 select
#6.subquery:包含在 select 中的子查询(不在 from 子句中)

 

posted @ 2020-08-04 18:50  wuxiaomiao  阅读(981)  评论(0编辑  收藏  举报