- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Find minimum score from the entire four columns of a table in MySQL
To find a minimum score from the entire four columns, use MySQL LEAST() function. Let us first create a table −
mysql> create table DemoTable( Score1 int, Score2 int, Score3 int, Score4 int ); Query OK, 0 rows affected (0.50 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(88,76,45,56); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable values(99,78,87,34); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(34,32,56,98); Query OK, 1 row affected (0.44 sec)
Display all records from the table using select statement &minsu;
mysql> select *from DemoTable;
This will produce the following output −
+--------+--------+--------+--------+ | Score1 | Score2 | Score3 | Score4 | +--------+--------+--------+--------+ | 88 | 76 | 45 | 56 | | 99 | 78 | 87 | 34 | | 34 | 32 | 56 | 98 | +--------+--------+--------+--------+ 3 rows in set (0.00 sec)
Following is the query to find minimum score from four columns of the database −
mysql> select least(Score1,Score2,Score3,Score4) AS MinimumScore from DemoTable;
This will produce the following output −
+--------------+ | MinimumScore | +--------------+ | 45 | | 34 | | 32 | +--------------+ 3 rows in set (0.00 sec)
- Related Articles
- Find and Replace text in the entire table using a MySQL?
- Get the highest score value from a single column and the greatest from two columns in MySQL
- How to find the number of columns in a MySQL table?
- Find minimum unused value in a MySQL table?
- Get the minimum value from a list with multiple columns in MySQL?
- Find the count of EMPTY or NULL columns in a MySQL table?
- C++ code to find rank of student from score table
- How to change a table (create/alter) so that the calculated “Average score” field is shown when querying the entire table without using MySQL INSERT, UPDATE?
- Get the number of columns in a MySQL table?
- Copy a few columns from a table to another in MySQL
- Need help in deleting duplicate columns from a table in MySQL?
- Select and add result of multiplying two columns from a table in MySQL?
- MySQL procedure with SELECT to return the entire table
- Program to find minimum difference of stone games score in Python
- How to combine date and time from different MySQL columns to compare with the entire DateTime?

Advertisements