Node.js MySQL Select from Table Last Updated : 07 Oct, 2021 Comments Improve Suggest changes Like Article Like Report Introduction: Learn about Selecting data from MySQL database using node.js. We are going to use standard SELECT FROM SQL Query. Syntax: SELECT [column] FROM [table_name] Example: 1) SELECT * FROM customers selecting all columns from customers table. 2) SELECT name, address FROM customers SQL users Table Preview: Example 1: select all columns from users table 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"); // This query will be used to select columns let query = 'SELECT * FROM users'; db_con.query(query, (err, rows) => { if(err) throw err; console.log(rows); }); }); Output: Example 2: select name column from users table 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"); // notice the name column below let query = 'SELECT name FROM users'; db_con.query(query, (err, rows) => { if(err) throw err; console.log(rows); }); }); Output: Comment More infoAdvertise with us Next Article Node.js MySQL Select from Table P pratikraut0000 Follow Improve Article Tags : Technical Scripter Web Technologies Node.js Technical Scripter 2020 NodeJS-MySQL +1 More Similar Reads Node.js MySQL Drop Table DROP TABLE Query is used to Delete or Drop a table from MySQL Database. Syntax: This will delete users table. But this will throw error if users table is not there. DROP TABLE users This will delete users table only if it exist. DROP TABLE IF EXISTS users Modules: mysql: To handle MySQL connection a 2 min read Node.js MySQL Create Table Introduction: Learn to create a table in MySQL database using NodeJS. We will see how to use the Create Table command in NodeJS using the MySQL module. Prerequisite: Introduction to NodeJS MySQL Setting up environment and Execution: Step 1: Create a NodeJS Project and initialize it using the followi 2 min read Node.js MySQL Insert into Table 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 th 3 min read Node.js MySQL-Create Table Using Sequelize Introduction to Sequelize: Sequelize is a promise-based Node.js ORM for Postgres, MySQL, MariaDB, SQLite and Microsoft SQL Server. Its features are solid transaction support, relations, eager and lazy loading, read replication and many more. Connect to MySql Database using Sequelize: To establish c 3 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 Like