如何从 MySQL 表中删除单行?
为了从 MySQL 表格中删除一行,可以使用 DELETE 语句,它带有一个 WHERE 从句,该从句指示特定行。
示例
mysql> Select * from names; +------+-----------+ | id | name | +------+-----------+ | 1 | Rahul | | 2 | Gaurav | | 3 | Raman | | 4 | Aarav | | 5 | Ram | +------+-----------+ 5 rows in set (0.00 sec) mysql> DELETE from names where id = 4; Query OK, 1 row affected (0.07 sec)
上面的查询将从表“名称”中删除标识符为 4 的行。
mysql> Select * from names; +------+-----------+ | id | name | +------+-----------+ | 1 | Rahul | | 2 | Gaurav | | 3 | Raman | | 5 | Ram | +------+-----------+ 4 rows in set (0.00 sec)
广告