Node.js MySQL FORMAT() Function Last Updated : 17 Feb, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report FORMAT() function is a built-in function in MySQL that is used to format input numbers in the format of ...**, ***, *** also, round float numbers to a specific number of decimal places. Syntax: FORMAT(number, number_of_decimal_places)Parameters: It takes two parameters as follows: number: The number which is given for formatting.number_of_decimal_places: It is the number of decimal places.Return Value: It returns a formatted number as a String in the format of ...**, ***, ***. Module Installation: Install the mysql module using the following command: npm install mysqlDatabase: 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 FORMAT(12345678.12555, 2) AS output"; db_con.query(query, (err, rows) => { if(err) throw err; console.log(rows); }); }); Run the index.js file using the following command: node index.jsOutput: 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 FORMAT(salary, 1) AS formatted_salary 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.jsOutput: Comment More infoAdvertise with us Next Article Node.js MySQL Count() Function P pratikraut0000 Follow Improve Article Tags : Technical Scripter Web Technologies Node.js Technical Scripter 2020 NodeJS-MySQL +1 More Similar Reads Node.js MySQL Count() Function We use the COUNT() function in MySQL to count a number of rows in a column satisfying the WHERE clause. Syntax: COUNT([column_name]) Parameters: COUNT() function accepts a single parameter as mentioned above and described below. column_name: Columnâs name from which we have to return the count value 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 CONCAT_WS() Function CONCAT_WS() function is a built-in function in MySQL that is used to concatenate a set of strings with a commonly given separator. Syntax: CONCAT_WS(separator, string_1, string_2, ...)Parameters: It takes two parameters as follows: separator: This separator will be used to concatenate strings.string 2 min read Node.js MySQL FIELD() Function FIELD() function is a built-in function in MySQL that is used to get the position of the first occurrence of a value in a set of expressions. In the case of string values, it is not case-sensitive. Syntax: FIELD(value, input_1, input_2, input_3, ...)Parameters: It takes two parameters as follows: va 2 min read 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 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 Like