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

What is the php sql delete statement?

藏色散人
Release: 2023-03-06 14:22:01
Original
2495 people have browsed it

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
Copy after login

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);
?>
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template