Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Node.js MySQL UPPER() Function

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

UPPER() function is a built-in function in MySQL that is used to convert all characters of a given string to uppercase.

Syntax:

UPPER(input_string)

Parameters: It takes one parameter as follows:

  • input_string: It is the given string that is passed for conversion to uppercase.

Return Value: It returns a new uppercase string.

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:

Database table

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 UPPER('This iNpUT 
          strinG @!#$%^&*()?') AS uppercase_name";
  
    db_con.query(query, (err, rows) => {
        if(err) throw err;
  
        console.log(rows);
    });
});

Run the index.js file using the following command:

node index.js

Output:

index.js file execution

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 name, UPPER(name) AS 
              uppercase_name FROM publishers";
  
    db_con.query(query, (err, rows) => {
        if(err) throw err;
  
        console.log(rows);
    });
});

Run the index.js file using the following command:

node index.js

Output:

index.js file execution


My Personal Notes arrow_drop_up
Last Updated : 29 Nov, 2021
Like Article
Save Article
Similar Reads
Related Tutorials