Node JS - Node js MySQL Delete - myssql - Node - Node JS tutorial - webnode




Delete Record :

  • You can delete records from an existing table by using the "DELETE " statement in mysql.
 node-js delete table

Learn Node js - node js Tutorial - node-js delete table - - node - Node js Examplesnode-js delete table

Example

  • Delete any record with the address "Mountain 21":
var mysql = require('mysql');

var con = mysql.createConnection({
  host: "localhost",
  user: "yourusername",
  password: "yourpassword",
  database: "mydb"
});

con.connect(function(err) {
  if (err) throw err;
  var sql = "DELETE FROM customers WHERE address = 'Mountain 21'";
  con.query(sql, function (err, result) {
    if (err) throw err;
    console.log("Number of records deleted: " + result.affectedRows);
  });
});

Notice the WHERE clause in the DELETE syntax:

  • The WHERE clause specifies which record or records that should be deleted.
  • If you omit the WHERE clause, all records will be deleted!
  • Save the code above in a file called "wikitechy_db_delete.js" and run the Node JS Tutorial File:
Run "wikitechy_db_delete.js"
C:\Users\Your Name>node wikitechy_db_delete.js 

Output:

Number of records deleted: 1 

This wikitechy technological portal provides you whole lot of information related to the topics such as mongodb tutorial , what is node js , express js tutorial , node js tutorial pdf , learn node js , node js tutorial for beginners , node js tutorial w3schools , node js express , javascript for beginners , node js express tutorial , node js tutorial point , node js book , node js server , note js , node js mongodb , what is node js used for , why node js , node tutorial , node js basics , tutorialspoint node js , node express , node js sample application , nodeschool , node js for beginners , express tutorial , node js application , use of node js , npm tutorial , node js org , node js training , node js online training , node js tutorial beginner , how to use node js , node js hello world , express node js , node js mongodb tutorial , nodejs http , why use node js

Related Searches to Node.js MySQL Delete

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add wikitechy.com to your ad blocking whitelist or disable your adblocking software.

×