How to Delete Data in Table in MySql

How to delete data in table in mysql - The delete process is done if there are data or records in a table that need to be deleted or removed. Changes that occur in the delete process are permanent, meaning that after the command is executed can not be canceled (undo). So be careful with the delete command!
We recommend that you first review the previous article about:
How to Insert Data Into The Table in MySql
How to Update Table Data in MySql
The general form of SQL commands to delete a record or data from a table is as follows:
DELETE FROM table_name [WHERE condition];
In the command to delete above:
  • DELETE FROM is the basic command to delete a record from the table.
  • table_name is the name of the table to delete the record.
  • The WHERE command is followed by a certain condition that determines which record to delete. This WHERE command may or may not.
However, if WHERE is not added to the delete command all records in the table will be deleted. So do not forget to add WHERE if we do not intend to empty the table.

How to delete row in table in mysql

Consider some examples of the REMOVE command from the following student table!
1. Delete the data of students who have studnetnumber 201052166
DELETE FROM student WHERE studentnumber='201052166';
And if the above query is executed then the results will be displayed as follows:
Query OK, 1 row affected (0.03 sec)
How to Delete Data in Table in MySql

2. Delete all students who are addressed in "Bandung"
DELETE FROM student WHERE address='Bandung';
How to Delete Data in Table in MySql

That is a tutorial that we can provide about how to delete data in table in mysql, hopefully can provide benefits and can increase our knowledge of the php programming language.

Comments