从MySQL表格的整个四列中找到最低分
要从全部四列中找到最低分,请使用MySQLLEAST()函数。让我们首先创建一个表-
create table DemoTable( Score1 int, Score2 int, Score3 int, Score4 int );
使用插入命令在表中插入一些记录-
insert into DemoTable values(88,76,45,56); insert into DemoTable values(99,78,87,34); insert into DemoTable values(34,32,56,98);
使用select语句&minsu;显示表中的所有记录。
select *from DemoTable;
这将产生以下输出-
+--------+--------+--------+--------+ | Score1 | Score2 | Score3 | Score4 | +--------+--------+--------+--------+ | 88 | 76 | 45 | 56 | | 99 | 78 | 87 | 34 | | 34 | 32 | 56 | 98 | +--------+--------+--------+--------+ 3 rows in set (0.00 sec)
以下是从数据库的四列中查找最低分数的查询-
select least(Score1,Score2,Score3,Score4) AS MinimumScore from DemoTable;
这将产生以下输出-
+--------------+ | MinimumScore | +--------------+ | 45 | | 34 | | 32 | +--------------+ 3 rows in set (0.00 sec)
热门推荐
10 周岁生日祝福语简短男孩
11 顺利毕业家人祝福语简短
12 祝福语老师诗词朗诵简短
13 搬乔迁新居祝福语简短
14 邮政贺卡生日祝福语简短
15 同事工作转正祝福语简短
16 生日的祝福语 文案简短
17 同学朋友吃饭祝福语简短
18 领证结婚搞笑祝福语简短