从MySQL列中获取最大值?
让我们首先创建一个表-
mysql> create table DemoTable -> ( -> Value int -> );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable values(78); mysql> insert into DemoTable values(89); mysql> insert into DemoTable values(98); mysql> insert into DemoTable values(58);
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
这将产生以下输出-
+-------+ | Value | +-------+ | 78 | | 89 | | 98 | | 58 | +-------+ 4 rows in set (0.00 sec)
以下是从列获取最大值的查询-
mysql> select Value from DemoTable order by Value DESC limit 1;
这将产生以下输出-
+-------+ | Value | +-------+ | 98 | +-------+ 1 row in set (0.00 sec)