In mysql, you can use the DELETE statement with the WHERE clause and LIMIT clause to delete a row of data in the table. The syntax is "DELETE FROM table name WHERE deletion condition LIMIT 1;"; the DELETE statement is used to delete the table One or more rows of data, the WHERE clause is used to set deletion conditions, and the LIMIT clause is used to set the number of rows to delete data.
The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
In mysql, you can use the DELETE statement with the WHERE clause and LIMIT clause to delete a row of data in the table.
DELETE FROM <表名> [WHERE 子句] [LIMIT 子句]
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.
If you want to delete a row of data in the table, you need to set LIMIT 1
.
DELETE FROM 表名 WHERE 删除条件 LIMIT 1;
Example:
Create a tb_students_score table, insert the data, and query all data
SELECT * FROM tb_students_score;
Delete A row of data with a score greater than 90
DELETE FROM tb_students_score WHERE student_score>90 LIMIT 1;
ok, a row of data with a student_score field value of 99 is deleted.
[Related recommendations: mysql video tutorial]
The above is the detailed content of How to delete a row of data in mysql table. For more information, please follow other related articles on the PHP Chinese website!