Last Updated: 29 June, 2023
The MIN() function in MySQL is used to retrieve the minimum value from a column or expression within a specified table.
Here's the basic syntax of the MIN() function:
SELECT MIN(column_name) FROM table_name;
The column_name represents the name of the column from which we want to retrieve the minimum value, and table_name is the name of the table containing the column.
Here's an example to illustrate its usage. Let's say we have a table named students with columns student_id and age, and we want to find the minimum age among all the students
SELECT MIN(age) FROM students;
This query will return the minimum age from the age column in the students table.
We can also use the MIN() function with other clauses like WHERE to specify conditions. For instance, if we want to find the minimum age among the students who are from a specific city:
SELECT MIN(age) FROM students WHERE city = 'New York';
This query will return the minimum age from the age column, considering only the students from New York.
Remember that the MIN() function can be used with other aggregate functions and in combination with the GROUP BY clause to retrieve the minimum value for each group in a table.
That's all, guys. I hope this MySQL article is helpful for you.
Happy Learning... 😀
feedback@javabytechie.com