Home > Database > SQL > body text

How to delete data using sql statement

angryTom
Release: 2020-02-07 13:16:18
Original
42282 people have browsed it

How to delete data using sql statement

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 ...;
Copy after login

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;
Copy after login

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;
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template