Node.js MySQL CONCAT_WS() Function Last Updated : 17 Feb, 2021 Comments Improve Suggest changes Like Article Like Report 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: It is the set of given input strings separated by comma(',').Return Value: It returns a string which is the concatenation of a set of strings with common given separator. 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 CONCAT_WS(' # ', 'Geeks', 'for', 'Geeks') 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 CONCAT_WS(': $', name, salary) AS Info 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 CONCAT_WS() 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 CONCAT_WS() Function in MySQL CONCAT_WS() : This function in MySQL helps in joining two or more strings along with a separator. The separator must be specified by the user and it can also be a string. If the separator is NULL, then the result will also be NULL. Syntax : CONCAT_WS(separator, string1, string2, ...) Parameters : se 2 min read Node.js MySQL FORMAT() Function 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 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 Like