我们可以使用DELETE语句和WHERE子句,来删除MySQL表中的特定行。
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)
上面的查询将从表 ‘names’ 中删除一个id = 4的行。
mysql> Select * from names;
+------+-----------+
| id | name |
+------+-----------+
| 1 | Rahul |
| 2 | Gaurav |
| 3 | Raman |
| 5 | Ram |
+------+-----------+
4 rows in set (0.00 sec)
登录后复制
以上就是我们如何从MySQL表中删除单行数据?的详细内容,更多请关注每日运维网(www.mryunwei.com)其它相关文章!