如何在mysql中删除行? [英] How to delete a row in mysql?
本文介绍了如何在mysql中删除行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以从MySql中的表中删除一个或多个行?我想从下表中删除最后两行。
Is it possible to delete one or more rows from a table in MySql ? I want to delete the last two rows from the following table.
+-------+--------------+-----------+--------------------+---------------+
| gp_no | no_of_member | amount | current_instalment | starting_date |
+-------+--------------+-----------+--------------------+---------------+
| 1 | 15 | 375000.00 | 2 | 2015-05-01 |
| 2 | 10 | 300000.00 | 1 | 2015-07-01 |
| 3 | 15 | 450000.00 | 5 | 2015-04-01 |
| 4 | 10 | 400000.00 | 0 | 2015-09-01 |
| 5 | 10 | 400000.00 | 0 | 2015-07-01 |
+-------+--------------+-----------+--------------------+---------------+
推荐答案
如果 gp_no
是主键并自动递增,则可以将最后2条记录删除为
If gp_no
is primary key and auto-incremented you can delete last 2 records as
delete from table_name order by gp_no desc limit 2
这篇关于如何在mysql中删除行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文