
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Delete a specific record on the basis of EmployeeId in MySQL
Let us first create a table −
mysql> create table DemoTable615 (EmployeeId varchar(100),EmployeeName varchar(100)); Query OK, 0 rows affected (0.62 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable615 values('EMP-101','Adam'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable615 values('EMP-1001','David'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable615 values('EMP-1002','Chris'); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable615 values('EMP-1003','Robert'); Query OK, 1 row affected (0.21 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable615;
This will produce the following output −
+------------+--------------+ | EmployeeId | EmployeeName | +------------+--------------+ | EMP-101 | Adam | | EMP-1001 | David | | EMP-1002 | Chris | | EMP-1003 | Robert | +------------+--------------+ 4 rows in set (0.00 sec)
Following is the query to delete a specific record −
mysql> delete from DemoTable615 where EmployeeId='EMP-1002'; Query OK, 1 row affected (0.13 sec)
Let us check table records once again −
mysql> select *from DemoTable615;
This will produce the following output −
+------------+--------------+ | EmployeeId | EmployeeName | +------------+--------------+ | EMP-101 | Adam | | EMP-1001 | David | | EMP-1003 | Robert | +------------+--------------+ 3 rows in set (0.00 sec)
- Related Articles
- Delete a specific record from a MySQL table by using AND in WHERE clause
- MySQL query to place a specific record on the top
- Update record on a specific date matching the current date in MySQL
- How to delete last record (on condition) from a table in MySQL?
- Delete a record with tablename.columnname= value in MySQL
- Display only a specific duplicate record in MySQL
- Get the record of a specific year out of timestamp in MySQL?
- MySQL query to delete a record with the lowest ID?
- How do I exclude a specific record in MySQL?
- How to select record except the lower value record against a specific value in MySQL?
- Implement specific record ordering with MySQL
- MySQL CONCAT a specific column value with the corresponding record
- MySQL query to decrease the value of a specific record to zero?
- MySQL db query to fetch records from comma separate values on the basis of a specific value
- Delete specific record from an array nested within another array in MongoDB?

Advertisements