Get the App
SLTechnology News&Howtos  ›  Database  › 

How mysql uses delete

Shulou Source: shulou.com Published: 2022-06-01 03:25:36 11月09日 Update

How does mysql use delete? This problem may be often seen in our daily study or work. I hope you can gain a lot from this question. The following is the reference content that the editor brings to you, let's take a look at it!

The delete statement in MySQL is generally used to delete one or more rows of data from a table.

The following is the general syntax for the SQL DELETE statement to delete data from the MySQL data table:

DELETE FROM [WHERE clause] [ORDER BY clause] [LIMIT clause] DELETE FROM table_name [WHERE Clause]

Specifies the name of the table to delete the data

ORDER BY clause: optional. When you delete, the rows in the table are deleted in the order specified in the clause.

WHERE clause: optional. Indicates that the deletion condition is qualified for the delete operation, and if the clause is omitted, all rows in the table are deleted.

LIMIT clause: optional. Used to tell the server the maximum value of the deleted row before the control command is returned to the client.

The WHERE clause is very useful when you want to delete a specified record in a data table. To limit the number of rows to delete, you can use the limit clause with Order By.

Delete the data in the table according to the condition

In the tb_courses_new table, delete the record with a course_id of 4, and enter the SQL statement and the execution result as shown below.

The following needs to be done on the command line.

Mysql > SELECT * FROM tb_courses+-+ | course_id | course_name | course_grade | course_info | +- -+-+ | 1 | Network | 3 | Computer Network | | 2 | Database | 3 | MySQL | 3 | Java | 4 | Java EE | | 4 | Php | 4 | phpstudy | +- -+ 4 rows in set (0.00 sec) mysql > DELETE FROM tb_courses-> WHERE course_id=4 Query OK, 1 row affected (0.00 sec) mysql > SELECT * FROM tb_courses +-+ | course_id | course_name | course_grade | course_info | +-+ -+ | 1 | Network | 3 | Computer Network | | 2 | Database | 3 | MySQL | | 3 | Java | 4 | Java EE | +- -+-+ 3 rows in set (0.00 sec) Thank you for reading! After reading the above, do you have a general idea of how mysql uses delete? I hope the content of the article will be helpful to all of you. If you want to know more about the relevant articles, you are welcome to follow the industry information channel.

Tags: Clause data content statement middle finger command datasheet article condition question maximum line representative client client more maximum useful server look Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL vpn Microsoft NVidia Shulou Technology