- 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
How to find the minimum values of two or more fields in MySQL?
To find the minimum values of two or more fields, use LEAST() function from MySQL −
select least(yourColumnName1,yourColumnName2,...N) from yourTableName;
Let us first create a table −
mysql> create table DemoTable -> ( -> Date1 date, -> Date2 date, -> Date3 date -> ); Query OK, 0 rows affected (0.54 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('2019-03-31','2019-01-01','2019-03-05'); Query OK, 1 row affected (0.17 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
Output
This will produce the following output −
+------------+------------+------------+ | Date1 | Date2 | Date3 | +------------+------------+------------+ | 2019-03-31 | 2019-01-01 | 2019-03-05 | +------------+------------+------------+ 1 row in set (0.00 sec)
Following is the query to retrieve the minimum value in MySQL −
mysql> select least(Date1,Date2,Date3) from DemoTable;
Output
This will produce the following output −
+--------------------------+ | least(Date1,Date2,Date3) | +--------------------------+ | 2019-01-01 | +--------------------------+ 1 row in set (0.04 sec)
- Related Articles
- Biggest value from two or more fields in MySQL?
- How can we combine the values of two or more columns of MySQL table?
- How to delete fields with values more than a particular value in MySQL?
- How to add two or more strings in MySQL?
- C# program to find common values from two or more Lists
- MySQL query to get the count of rows in which two or more specified values appear?\n
- How to find the intersection between two or more lists in R?
- How to find the number of rows in a data.table where two or more column values meet a criteria in R?
- How to find the minimum and maximum values in a single MySQL Query?
- Is there a way to retrieve the minimum value of fields in MySQL?
- MySQL query to order by two fields and NULL values in chronological order?
- How to find the common elements between two or more arrays in JavaScript?
- How can we combine values of two or more columns of MySQL table and get that value in a single column?
- C# program to find Union of two or more Lists
- Python program to find Union of two or more Lists?

Advertisements