Node.js MySQL INSTR() Function Last Updated : 17 Feb, 2021 Comments Improve Suggest changes Like Article Like Report INSTR() function is a built-in function in MySQL that is used to get the position of the first occurrence of pattern in the text. Note: In NodeJs MySQL, INSTR() function is not case sensitive. Syntax: INSTR(text, pattern)Parameters: It takes two parameters as follows: text: It is the given text in which the pattern is searched.pattern: It is the pattern which the user wants to search in the text.Return Value: It returns a position number of the first occurrence of pattern in the text. If occurrence not found then it will return 0. 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 INSTR('GeeksForGeeks', 'geek') AS position"; 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 INSTR(name, 'n') AS position 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 INSTR() 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 INSERT() Function INSERT() function is a built-in function in MySQL that is used to insert a string into another string at some position after deleting some characters from it. Syntax: INSERT(string_1, position, number_of_characters_to_delete, string_2)Parameters: It takes four parameters as follows: string_1: It is 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 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 FIND_IN_SET() Function FIND_IN_SET() function is a built-in function in MySQL that is used to get the position of the first occurrence of value string in a list of strings separated by comma(','). Syntax: FIND_IN_SET(value, list_of_string)Parameters: It takes two parameters as follows: value: It is the value to be searche 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 Min() Function 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() 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 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 TRIM() Function TRIM() function is a built-in function in MySQL that is used to trim all spaces from both sides of the input string. Syntax: TRIM(string)Parameters: It takes one parameter as follows: string: It is the string to be trimmed from both sides.Return Value: It returns string after trimming from both side 2 min read Like