Node.js MySQL OR Operator Last Updated : 07 Oct, 2021 Comments Improve Suggest changes Like Article Like Report NodeJs: An open-source platform for executing javascript code on the server-side. Also, a javascript runtime built on Chrome’s V8 JavaScript engine. It can be downloaded from here. Mysql An open-source Relational Database Management System (RDBMS) that uses Structured Query Language (SQL). It is the most popular language for adding, accessing, and managing content in a database. Here we will use the Mysql as a database for our node application. It can be downloaded from here. OR operator: This Operator is a logical operator and used to fetch records from the table when either one of the conditions is true. We use OR Operator to set a basic union query in MySQL. Syntax: SELECT [column_name(s)] FROM [table_name] WHERE condition1 OR condition2 OR condition3 ... Module: mysql: mysql module is used for interaction between the MySQL server and the node.js application. Installing Module: npm install mysql SQL users Table preview: Example 1: index.js JavaScript //Importing mysql module const mysql = require("mysql"); //Creating connection 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"); // Query to be executed let query = "SELECT * FROM users WHERE id = 3 OR name = 'rohan'"; //Executing the query db_con.query(query, (err, rows) => { if(err) throw err; console.log(rows); }); }); Run index.js file using below command: node index.js Console Output: Example 2: index.js JavaScript //Importing mysql module const mysql = require("mysql"); //Creating connection 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"); // Query to be executed let query = "SELECT * FROM users WHERE id = 3 OR name = 'rohan' OR address = 'sideway'"; // Executing query db_con.query(query, (err, rows) => { if(err) throw err; console.log(rows); }); }); Run index.js file using below command: node index.js Console Output: Comment More infoAdvertise with us Next Article Node.js MySQL OR Operator P pratikraut0000 Follow Improve Article Tags : Technical Scripter Web Technologies Node.js Technical Scripter 2020 NodeJS-MySQL +1 More Similar Reads Node.js MySQL UPPER() Function 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 2 min read Node.js MySQL Order By Clause Introduction: We use the SQL ORDER BY Clause to sort the data with respect to some column value in ascending or descending order. Syntax: SELECT * FROM users ORDER BY name; This will sort all rows of output in ascending order (by default) with respect to name column. SELECT address FROM users ORDER 2 min read Node.js MySQL Delete Query We use SQL DELETE Query to delete data with some condition from MySQL Table. Syntax: This will delete all rows of customers' tables but everything else will remain as it is (indexing, etc). DELETE FROM users This will delete all rows of users table where userId is 2. DELETE FROM users WHERE userId = 2 min read Node.js MySQL Update Statement Node.js is an open-source platform for executing JavaScript code on the server-side. It can be downloaded from here. MySQL is an open-source Relational Database Management System (RDBMS) that uses Structured Query Language (SQL). It is the most popular language for adding, accessing, and managing co 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