Home >Database >Mysql Tutorial >How to delete a row of data in mysql table

How to delete a row of data in mysql table

青灯夜游
青灯夜游Original
2022-06-21 17:01:5814315browse

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.

How to delete a row of data in mysql table

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;

How to delete a row of data in mysql table

Delete A row of data with a score greater than 90

DELETE FROM tb_students_score WHERE student_score>90 LIMIT 1;

How to delete a row of data in mysql table

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!

Statement:
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