Blog Bustle 08/02/2020
Delete query is used to delete records in table. Many records can be deleted at a time. It depends on where condition.
You can specify one or more condition by using where clause and combine more conditions by using 'and/or' operator.
delete from student where name='mihir'
delete from student where name='mihir' and email ='firstname.lastname@example.org'
both condition should be true in this delete query in sql otherwise table will remain same as before.
delete from student where name='mihir' or name ='harshit'
atleast one condition should be true in this delete query in sql otherwise table will remain same as before.
There are two methods to write delete query in mysql:
We have student table.
We want to delete all rows in table where email is 'email@example.com' and name is 'mihir' then query will be
delete from student where firstname.lastname@example.org' and name='mihir'
If we do not write where condition in delete query in sql, all rows from student table will get deleted. We are going to delete all rows in student table and query will be
delete from student