Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • NodeJS Tutorial
  • NodeJS Exercises
  • NodeJS Assert
  • NodeJS Buffer
  • NodeJS Console
  • NodeJS Crypto
  • NodeJS DNS
  • NodeJS File System
  • NodeJS Globals
  • NodeJS HTTP
  • NodeJS HTTP2
  • NodeJS OS
  • NodeJS Path
  • NodeJS Process
  • NodeJS Query String
  • NodeJS Stream
  • NodeJS String Decoder
  • NodeJS Timers
  • NodeJS URL
  • NodeJS Interview Questions
  • NodeJS Questions
  • Web Technology
Open In App
Next Article:
Node.js MySQL LTRIM() Function
Next article icon

Node.js MySQL Min() Function

Last Updated : 07 Oct, 2021
Comments
Improve
Suggest changes
Like Article
Like
Report

We will be using Min() function in MySQL to get Minimum value from some particular column.

Syntax:

MIN(column_name)

Parameters: MIN() function accepts a single parameter as mentioned above and described below.

  • column_name: Column’s name from which we have to return the min value.

Return Value: MIN() function returns the minimum value from the particular column in the table.

Module Installation: Install the MySQL module using the following command.
npm install mysql
Database: Our SQL publishers table preview with sample data is shown below.

Example 1:

index.js
const mysql = require("mysql");  let db_con  = mysql.createConnection({     host: "localhost",     user: "root",     password: '',     database: 'gfg_db' });  db_con.connect((err) => {     if (err) {       console.log("Database Connection Failed !!!", err);       return;     }      console.log("We are connected to gfg_db database");      // Here is the query     let query = "SELECT MIN(salary) AS min_salary FROM publishers";      db_con.query(query, (err, rows) => {         if(err) throw err;          console.log(rows);     }); }); 

Output:

Example 2:

index.js
const mysql = require("mysql");  let db_con  = mysql.createConnection({     host: "localhost",     user: "root",     password: '',     database: 'gfg_db' });  db_con.connect((err) => {     if (err) {       console.log("Database Connection Failed !!!", err);       return;     }      console.log("We are connected to gfg_db database");      // Here is the query     let query = "SELECT MIN(salary) AS min_salary                   FROM publishers WHERE id < 7";      db_con.query(query, (err, rows) => {         if(err) throw err;          console.log(rows);     }); }); 

Output:


Next Article
Node.js MySQL LTRIM() Function

P

pratikraut0000
Improve
Article Tags :
  • Technical Scripter
  • Web Technologies
  • Node.js
  • Technical Scripter 2020
  • NodeJS-MySQL

Similar Reads

  • Node.js MySQL MID() Function
    MID() Function is a Builtin Function in MySQL which is used to get substring of input string between given range inclusive. Syntax: MID(input_string, from, length) Parameters: MID() function accepts three parameters as mentioned above and described below. input_string: Substring of this input will b
    2 min read
  • Node.js MySQL LTRIM() Function
    LTRIM() Function is a Builtin Function in MySQL which is used to trim all spaces from left side of input string. Syntax: LTRIM(string) Parameters: LTRIM() function accepts a single parameters as mentioned above and described below. string: String needed to be trimmed from left side Return Value: LTR
    2 min read
  • Node.js MySQL LEFT() Function
    LEFT() Function is a Builtin function in MySQL which is used to get Prefix of a specific size of Given String. Syntax: LEFT(input_string, size_of_prefix) Parameters: LEFT() function accepts two parameters as mentioned above and described below. input_string: We will get prefix of this input stringsi
    2 min read
  • Node.js MySQL LENGTH() Function
    LENGTH() Function is a Builtin function in MySQL which is used to get length of given string in bytes. Syntax: LENGTH(input_string) Parameters: LENGTH() function accepts a single parameter as mentioned above and described below. input_string: We will get number of characters of this string Return Va
    2 min read
  • Node.js MySQL LPAD() Function
    LPAD() Function is a Builtin function in MySQL which is used to attach a given string to text from left side till total length is equal to given value. If the given string is small then it is repeated multiple times. Syntax: LPAD(text, total_length, string) Parameters: LPAD() function accepts three
    2 min read
  • Node.js MySQL SUM() Function
    We use the SUM() function in MySQL to get Sum of the value of some columns. Syntax: SUM(column_name) Parameters: SUM() function accepts a single parameter as mentioned above and described below. column_name: Column’s name from which we have to return the max value. Module Installation: Install the m
    2 min read
  • Node.js MySQL AVG() Function
    We use AVG Function to get the average value of all rows in the given column of MySQL Table. Syntax: AVG([column_name]) Parameters: AVG() function accepts a single parameter as mentioned above and described below. column_name: Column’s name from which we have to return the average value. Module Inst
    2 min read
  • Node.js MySQL LOWER() Function
    LOWER() Function is a Builtin function in MySQL which is used to convert all characters of given string to lowercase. Syntax: LOWER(input_string) Parameters: LOWER() function accepts a single parameter as mentioned above and described below. input_string: We will convert this string to lowercase Ret
    2 min read
  • Node.js MySQL LCASE() Function
    LCASE() function is a built-in function in MySQL that is used to convert all characters of a given string to lowercase. Syntax: LCASE(input_string)Parameters: It takes one parameter as follows: input_string: Input string which is passed as a parameter to convert this string to lowercase.Return Value
    2 min read
  • Node.js MySQL LOCATE() Function
    LOCATE() Function is a Builtin function in MySQL which is used to get position of first occurrence of a pattern in a text when searched from specific position. Note: It is Not Case Sensitive. Syntax: LOCATE(pattern, text, starting_position) Parameters: LOCATE() function accepts three parameters as m
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences