Software Testing

k2G9Eo9
RdZQRt6

Popular Posts

DELETE

The DELETE statement is used to delete a single record or multiple records from a table in MySQL.
The basic syntax is as follows:
DELETE FROM table WHERE conditions;
EXAMPLE - WITH ONE CONDITION
Let's look at a simple MySQL DELETE query example, where we just have one condition in the DELETE statement.
For example:
DELETE FROM contacts WHERE Name = 'Dipesh';
We have Employee Table
Employee
Emp_idNameSurnameSalaryDept_id
1RajeshKhanna450002
2SnehaGupta550004
3SandeepNehte950001
4KirtiPatil250003
5NileshJadhav450003
6DipeshDas350005
7KailashRane620001
8KavitaDeshpande480003
9SanjayDatt500003
10ShrutiHasan780001

After Execute: 
(1 row(s) affected)
(0 ms taken)

Emp_idNameSurnameSalaryDept_id
1RajeshKhanna450002
2SnehaGupta550004
3SandeepNehte950001
4KirtiPatil250003
5NileshJadhav450003
7KailashRane620001
8KavitaDeshpande480003
9SanjayDatt500003
10ShrutiHasan780001
EXAMPLE - WITH TWO CONDITIONS
Let's look at a MySQL DELETE example, where we just have two conditions in the DELETE statement.
For example:
DELETE FROM contacts WHERE Name = 'Sanjay' AND Salary < 30000;
This MySQL DELETE example would delete all records from the contacts table where the last_name is 'Johnson' and the customer_id is less than 1000

No comments:

Post a Comment