Node.js Tutorial

Node.js MySQL Delete Records

Node.js MySQL Delete Records

Node.js MySQL: Delete Records

The MySQL DELETE FROM command removes one or more records from a table ÔÇö an essential part of CRUD operations. This guide shows you how to do it from Node.js using the mysql package.

Node.js Tutorial:-
SQL Tutorial:-

Example: Delete by City

// delete.js
var mysql = require('mysql');

var con = mysql.createConnection({
  host: "localhost",
  user: "root",
  password: "12345",
  database: "updategadh"
});

con.connect(function(err) {
  if (err) throw err;
  const sql = "DELETE FROM employees WHERE city = 'Delhi'";
  con.query(sql, function (err, result) {
    if (err) throw err;
    console.log("Records deleted:", result.affectedRows);
  });
});

Run It

node delete.js

Parameterized DELETE (Safer)

const sql = "DELETE FROM employees WHERE city = ?";
con.query(sql, ['Delhi'], (err, result) => {
  if (err) throw err;
  console.log(`${result.affectedRows} deleted`);
});

Verify

SELECT * FROM employees;
-- The Delhi rows should be gone

Important

Without a WHERE clause, DELETE removes ALL rows. Always include a condition unless you mean to empty the table.

Download New Real Time Projects:- Click here
Complete Advance AI topics:-

Conclusion

Deleting MySQL records from Node.js is one parameterized query. Use placeholders and always log affectedRows to confirm. For more tutorials, stay tuned to .

nodejs mysql delete
mysql delete query nodejs
node.js mysql delete
delete query in node js
delete a record mysql db
mysql delete join
node js mysql delete data
node js mysql delete records example

Source Code Available

Interested in This Project?

Get the complete source code for this project at a very affordable price — perfect for your portfolio, college submission, or learning. Message us on WhatsApp and we'll get back to you instantly!

Full source code included Step-by-step setup guide Instant delivery on WhatsApp Instant reply on WhatsApp
Chat on WhatsApp

We usually reply within a few minutes

Leave a Reply

Your email address will not be published. Required fields are marked *

Chat with us