
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Is there a way to retrieve the minimum value of fields in MySQL?
Yes, you can 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 Questions & Answers
- Is there a way to select a value which matches partially in MySQL?
- What is the proper way to retrieve the value stored in INT column as MySQL TIMESTAMP?
- Is there a way to know your current username in MySQL?
- Is there any way in MongoDB to get the inner value of json data?
- Is there a way to subtract number of days from a date in MySQL?
- Is there any way to check if there is a null value in an object or array in JavaScript?
- In MySQL, is there a way to turn column records into a list?
- Is there an easy way to rename a table in a MySQL procedure?
- Is there a way to list collections in MongoDB?
- Is there a way to make a list from a MySQL table in Java?
- Is there a way to name columns in an INSERT statement in MySQL?
- Is there a way to change the date format in php?
- Is there a way to list all the reserved words in MySQL using the MySQL command-line utility?
- Is there a default ORDER BY value in MySQL?
- Is there a way in MySQL to reverse a boolean field with a single query?
Advertisements