Home >Backend Development >PHP Problem >What is the php sql delete statement?

What is the php sql delete statement?

藏色散人
藏色散人Original
2020-10-08 16:14:192453browse

php sql delete statement is "DELETE FROM", which is used to delete rows from the database table. Its syntax is "DELETE FROM table_name WHERE column_name = some_value".

What is the php sql delete statement?

Recommended: "PHP Video Tutorial"

PHP MySQL Delete From

DELETE FROM statement is used to delete rows from a database table.

Delete data in the database

The DELETE FROM statement is used to delete records from the database table.

Syntax

DELETE FROM table_name
WHERE column_name = some_value

Note: SQL is not case sensitive. DELETE FROM is equivalent to delete from.

In order for PHP to execute the above statement, we must use the mysql_query( function. This function is used to send queries and commands to the SQL connection.

The following example deletes all LastNames in the "Persons" table ='Griffin' record:

<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
  {
  die(&#39;Could not connect: &#39; . mysql_error());
  }
mysql_select_db("my_db", $con);
mysql_query("DELETE FROM Persons WHERE LastName=&#39;Griffin&#39;");
mysql_close($con);
?>

The above is the detailed content of What is the php sql delete statement?. 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