SQL statement method to delete data
If we want to delete the data in the table in the database, we can use the DELETE statement .
The basic syntax of the DELETE statement is:
DELETE FROM <表名> WHERE ...;
For example, if we want to delete the record with id=10 in the user table, we can write like this:
DELETE FROM user WHERE id = 10;
Note:
1. If the WHERE condition does not match any records, the DELETE statement will not report an error and no records will be deleted.
2. The DELETE statement without the WHERE condition will delete the entire table data. :
DELETE FROM user;
At this time, all records in the entire table will be deleted. Therefore, you must be very careful when executing the DELETE statement. It is best to use the SELECT statement to test whether the WHERE condition filters out the desired record set, and then use DELETE to delete it.
PHP Chinese website has a large number of free SQL tutorials, everyone is welcome to learn!
The above is the detailed content of How to delete data using sql statement. For more information, please follow other related articles on the PHP Chinese website!