Category: 2. My SQL
-
Node.js MySQL Drop Table
The DROP TABLE command is used to delete or drop a table. Let’s drop a table named employee2. Create a js file named “delete” in DBexample folder and put the following data into it: Now open command terminal and run the following command: Verify that the table employee2 is no more in the database.
-
Node.js MySQL SELECT Unique Record
(WHERE Clause) Retrieve a unique data from the table “employees”. Create a js file named selectwhere.js having the following data in DBexample folder. Now open command terminal and run the following command: Node.js MySQL Select Wildcard Retrieve a unique data by using wildcard from the table “employees”. Create a js file named selectwildcard.js having the…
-
Node.js MySQL Select Records
Example Retrieve all data from the table “employees”. Create a js file named select.js having the following data in DBexample folder. Now open command terminal and run the following command: You can also use the statement:
-
Node.js MySQL Delete Records
The DELETE FROM command is used to delete records from the table. Example Delete employee from the table employees where city is Delhi. Create a js file named “delete” in DBexample folder and put the following data into it: Now open command terminal and run the following command: You can verify the deleted record by…
-
Node.js MySQL Update Records
The UPDATE command is used to update records in the table. Example Update city in “employees” table where id is 1. Create a js file named “update” in DBexample folder and put the following data into it: Now open command terminal and run the following command: It will change the city of the id 1 is…
-
Node.js MySQL Insert Records
INSERT INTO statement is used to insert records in MySQL. Example Insert Single Record: Insert records in “employees” table. Create a js file named “insert” in DBexample folder and put the following data into it: Now open command terminal and run the following command: Check the inserted record by using SELECT query: SELECT * FROM…
-
Node.js MySQL Create Table
CREATE TABLE command is used to create a table in MySQL. You must make it sure that you define the name of the database when you create the connection. Example For creating a table named “employees”. Create a js file named employees.js having the following data in DBexample folder. Now open command terminal and run…
-
Node.js MySQL Create Database
CREATE DATABASE statement is used to create a database in MySQL. Example For creating a database named “javatpoint”. Create a js file named javatpoint.js having the following data in DBexample folder. Now open command terminal and run the following command: You can see the database is created. Verification To verify if the database is created…
-
Node.Js Create Connection with MySQL
We can use Node.js in database applications. Here we use MySQL as a database with Node.js. Install MySQL on your computer. You can download it from here https://www.mysql.com/downloads/. Once the MySQL is installed and running, you can access it by using Node.js. Install MySQL Driver You have to install MySQL driver to access a MySQL database…