
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Delete Specific Record from MySQL Table using AND in WHERE Clause
MySQL AND is used in WHERE to fetch a record by filtering using multiple conditions. Let us first create a table−
mysql> create table DemoTable -> ( -> Id int, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.70 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(101,'Chris'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(102,'David'); Query OK, 1 row affected (0.51 sec) mysql> insert into DemoTable values(103,'Bob'); Query OK, 1 row affected (0.14 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable;
This will produce the following output −
+------+-------+ | Id | Name | +------+-------+ | 101 | Chris | | 102 | David | | 103 | Bob | +------+-------+ 3 rows in set (0.00 sec)
Here is the query to delete a record −
mysql> delete from DemoTable where Id=102 and Name='David'; Query OK, 1 row affected (0.20 sec)
Let us check the table records once again −
mysql> select * from DemoTable;
This will produce the following output −
+------+-------+ | Id | Name | +------+-------+ | 101 | Chris | | 103 | Bob | +------+-------+ 2 rows in set (0.00 sec)
Advertisements