In MySQL, you can use the DELETE statement to delete one or more rows of data in a table.
Delete data in a single table
Use the DELETE statement to delete data from a single table. The syntax format is:
1 |
|
The syntax is as follows:
ORDER BY clause: Optional. Indicates that when deleting, rows in the table will be deleted in the order specified in the clause.
WHERE clause: Optional. Indicates that the deletion conditions are limited for the deletion operation. If this clause is omitted, it means that all rows in the table are deleted.
LIMIT clause: Optional. Used to tell the server the maximum number of rows to be deleted before the control command is returned to the client.
Note: When the WHERE condition is not used, all data will be deleted.
Delete all data in the table
Delete all data in thetb_courses_new
table. The input SQL statement and execution results are as follows.
1 2 3 4 |
|
Delete data in the table based on conditions
In the tb_courses_new
table, delete the record with course_id 4, enter the SQL statement and execute it The results are shown below.
1 2 3 4 5 6 7 8 9 10 11 12 |
|
It can be seen from the running results that the record with course_id 4 has been deleted.
The above is the detailed content of How to delete data in mysql. For more information, please follow other related articles on the PHP Chinese website!