4.2.16. MySQL DELETE statement

发布时间 : 2025-10-25 13:32:49 UTC      

Page Views: 9 views

You can use SQL’s DELETE FROM command to delete records in the MySQL datasheet.

You can do it in the mysql> Execute the command at a command prompt or in a PHP script.

Grammar

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

DELETE FROM table_name [WHERE Clause] 
  • If no WHERE clause is specified, all records in the MySQL table are deleted.

  • You can specify any condition in the WHERE clause

  • You can delete records in a single table at once.

The WHERE clause is very useful when you want to delete a specified record in a data table.

Delete data from the command line

Here we will use the WHERE clause in the SQL DELETE command to delete the data selected by the MySQL data table runoob_tbl.

Example

The following instance will be deleted runoob_tbl In the table runoob_id A record of 3:

DELETE statement:

mysql>useRUNOOB;Databasechangedmysql>DELETEFROMrunoob_tblWHERErunoob_id=3;QueryOK,1rowaffected(0.23sec) 

Use PHP scripts to delete data

PHP usage mysqli_query() Function to execute the SQL statement, you can use it in the SQL DELETE command or not WHERE Clause.

This function is similar to the mysql> The command executes the SQL command with the same effect.

Example

The following PHP instances will be deleted runoob_tbl In the table runoob_id A record of 3:

MySQL DELETE clause test:

 
《地理信息系统原理、技术与方法》  97

最近几年来,地理信息系统无论是在理论上还是应用上都处在一个飞速发展的阶段。 GIS被应用于多个领域的建模和决策支持,如城市管理、区划、环境整治等等,地理信息成为信息时代重要的组成部分之一; “数字地球”概念的提出,更进一步推动了作为其技术支撑的GIS的发展。 与此同时,一些学者致力于相关的理论研究,如空间感知、空间数据误差、空间关系的形式化等等。 这恰好说明了地理信息系统作为应用技术和学科的两个方面,并且这两个方面构成了相互促进的发展过程。