Open In App

Node.js MySQL LOWER() Function

Last Updated : 29 Nov, 2021
Comments
Improve
Suggest changes
Like Article
Like
Report

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

Return Value: LOWER() function returns a new lowercase string.

Modules:

  • mysql: To handle MySQL Connection and Queries
npm install mysql

SQL publishers Table Preview:

Database table

Example 1:

JavaScript
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 LOWER('This iNpUT strinG @!#$%^&*()?') AS lowercase_name";

  db_con.query(query, (err, rows) => {
    if (err) throw err;

    console.log(rows);
  });
});

Output:

Node.js MySQL LOWER() Function 1

Example 2:

JavaScript
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 LOWER(name) AS lowercase_name FROM publishers";

  db_con.query(query, (err, rows) => {
    if (err) throw err;

    console.log(rows);
  });
});

Output:

Node.js MySQL LOWER() Function 2

Next Article

Similar Reads