带比较运算符的子查询
#比较运算符:=、!=、>、>=、<、<=、<>
#查询大于所有人平均年龄的员工名与年龄
思路 先拿到所有人的平均年龄然后 再用另外一条sql语句 进行比较 拿所有员工的年龄 > 所有人的平均年龄 做比较
mysql> select name,age from employee where age >(select avg(age) from employee) ; +------+------+ | name | age | +------+------+ | alex | 48 | | jack | 38 | +------+------+ 2 rows in set (0.00 sec)
原文地址:https://www.cnblogs.com/mingerlcm/p/9897754.html
时间: 2025-01-08 22:40:33