两种方法:
1. 使用max或者min函数
select max(age),min(age) from user2;
结果:
2. 使用order by 和limit 结合使用
- 取最大值
select age from user2 order by age desc limit 1;
- 取最小值
select age from user2 order by age limit 1;
本文共 249 字,大约阅读时间需要 1 分钟。
select max(age),min(age) from user2;
结果:
select age from user2 order by age desc limit 1;
select age from user2 order by age limit 1;
转载于:https://www.cnblogs.com/shyroke/p/9375925.html