用Delete 语句在数据库表中删除数据。
DELETE FROM table_name WHERE some_column=some_value;
DELETE FROM 数据表名 WHERE 某列=某值;
在test数据库里user表有以下数据:
+------+---------+----------+ | id | Name | password | +------+---------+----------+ | 1 | zhansan | 111 | | 2 | lisi | 111 | | 3 | liming | 111 | +------+---------+----------+
删除user表的数据
<?php $link = @mysqli_connect('localhost', 'root', 'root', 'test','3306'); if (!$link) { die('连接失败!'.mysqli_connect_error()); }else{ $sql = "DELETE FROM user"; $result = mysqli_query($link,$sql); echo "已删除!"; mysqli_close($link); } ?>
结果:
由于没有写WHERE字句条件,则是删除整张表的的数据 |