(笔记)Mysql命令delete from:删除记录
时间:2021-07-01 10:21:17
帮助过:2人阅读
delete from命令格式:delete from 表名 where 表达式例如,删除表 MyClass中编号为1 的记录: mysql> delete from MyClass where id=1;请对比一下删除数据前后表的变化。
FirstName | LastName | Age |
Peter |
Griffin |
35 |
Glenn |
Quagmire |
33 |
下面以PHP代码为例删除 "Persons" 表中所有 LastName=‘Griffin‘ 的记录:
- <?php
- $con = mysql_connect("localhost","peter","abc123");
- if (!$con){
- die(‘Could not connect: ‘ . mysql_error());
- }
- mysql_select_db("my_db", $con);
- mysql_query("DELETE FROM Persons WHERE LastName=‘Griffin‘"); mysql_close($con);
- ?>
在这次删除之后,表是这样的:
FirstName | LastName | Age |
Glenn |
Quagmire |
33
|
(笔记)Mysql命令delete from:删除记录
标签: