mysql> use test_db; Database changed mysql> SELECT * FROM tb_students_score; +--------------+---------------+ | student_name | student_score | +--------------+---------------+ | Dany | 90 | | Green | 99 | | Henry | 95 | | Jane | 98 | | Jim | 88 | | John | 94 | | Lily | 100 | | Susan | 96 | | Thomas | 93 | | Tom | 89 | +--------------+---------------+ 10 rows in set (0.13 sec)【实例 1】在 tb_students_score 表中查找最高的成绩,输入的 SQL 语句和执行结果如下所示。
mysql> SELECT MAX(student_score) -> AS max_score -> FROM tb_students_score; +-----------+ | max_score | +-----------+ | 100 | +-----------+ 1 row in set (0.06 sec)由运行结果可以看到,MAX() 函数查询出 student_score 字段的最大值为 100。
mysql> SELECT MAX(student_name) -> AS max_name -> FROM tb_students_score; +----------+ | max_name | +----------+ | Tom | +----------+ 1 row in set (0.03 sec)由运行结果可以看到,MAX() 函数可以对字母进行大小判断,并返回最大的字符或者字符串值。
本文链接:http://task.lmcjl.com/news/13008.html