In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how mysql deletes data. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.
Delete data from a single table
Use the DELETE statement to delete data from a single table in the syntax format:
DELETE FROM [WHERE clause] [ORDER BY clause] [LIMIT clause]
The syntax is as follows:
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.
Note: when the WHERE condition is not used, all data will be deleted.
Delete all data in the table
Delete all the data in the tb_courses_new table, enter the SQL statement and the execution result is shown below.
Mysql > DELETE FROM tb_courses_new;Query OK, 3 rows affected (0.12 sec) mysql > SELECT * FROM tb_courses_new;Empty set (0.00 sec)
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.
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)
As can be seen from the running results, the record with a course_id of 4 has been deleted.
Thank you for reading! On how to delete mysql data to share here, I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.