MySQL第9天

2022-09-11

子查询

子查询的定义:

  一个完整的select语句嵌套一个select语句。被嵌套的查询语句称为子查询,前面嵌套其他查询语句的称为主查询。

子查询的使用:

  以students表(id,name,age,gender,id_del,height,c_id)为例:

    查询学生表内大于平均年龄的学生的信息   

select * from students where age > (select avg(age) from students);

 

posted @ 2022-09-11 21:54  努力是一种常态  阅读(27)  评论(0)    收藏  举报