zoukankan      html  css  js  c++  java
  • mysql5.7innodb引擎底层分析:子查询种类回顾

    子查询种类回顾

    select * from (select m1 from t1 limit 1);  像这种只返回一个值的被称为标量子查询

    select * from (select * from t1 limit 1);  像这种只返回一行数据的子查询被称为行子查询,会有多个列返回。

    select * from (select m1 from t1 limit 10);  像这种返回一个列但是多行数据的子查询被称为列子查询

    select * from t1 where (m1, n1) = (select m2, n2 from t2);       返回多行多列的就是表子查询

    select * from t1 where m1 in ( select m2 from t2 where t1.id = t2.id );           子查询中有对外层关系的依赖,称为相关子查询

    select * from t1 where m1 in ( select m2 from t2 );      子查询中没有对外层关系的依赖,称为不相关子查询

    select * from t1 where m1 > ANY( select m2 from t2 );   等价于   select * from t1 where m1 > ( select min(m2) from t2 );

    select * from t1 where m1 > ALL( select m2 from t2 );   等价于   select * from t1 where m1 > ( select MAX(m2) from t2 );

    end.

    支付宝扫一扫,为女程序员打赏!
    作者:梦幻朵颜
    版权:本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    MySQL学习笔记:repeat、loop循环
    链表//相交链表
    单位和值
    链表//环形链表 II
    css样式设置小技巧
    链表//环形链表
    CSS代码缩写,占用更少的带宽
    CSS布局模型
    CSS盒模型
    CSS格式化排版
  • 原文地址:https://www.cnblogs.com/zhuwenjoyce/p/15027452.html
Copyright © 2011-2022 走看看