子查询(Subquery)是指出现在其他SQL语句内的SELECT子句。

例如:

select * from t1 where col1=(select col2 from t2);

其中select * from t1,称为Outer Query/Outer Statement(外层查询)

select col2 from t2,称为SubQuery(子查询)

 

子查询必须嵌套在查询内部,且必须始终出现在圆括号内

子查询可以包含多个关键字或条件,

如distinct  group by  order by  limit  函数等

子查询的外层查询可以是select  insert  update  set    或 do

子查询返回值

子查询可以返回标量、一行、一列或子查询。

相关文章:

  • 2021-12-05
  • 2022-12-23
  • 2022-01-31
  • 2021-07-10
  • 2022-12-23
  • 2021-07-30
  • 2022-12-23
  • 2021-12-28
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-22
  • 2022-12-23
  • 2021-11-05
  • 2022-03-01
相关资源
相似解决方案