我有一个包含 10 个高分的表,当新用户出现大于最低分的新高分时,我想从表中删除最低分。我已经尝试了所有建议的方法来做到这一点。请有人帮忙。
最佳答案
像这样的东西应该可以工作。您将在插入新记录后运行它。
delete from t t1 where t1.score not in
(select t2.score from t t2 order by t2.score desc limit 10)
如果表中的每条记录都有唯一的 ID,那么我将对其进行如下修改:
delete from t t1 where t1.id not in
(select t2.id from t t2 order by t2.score desc limit 10)
关于mysql - 从表中删除最小值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48286868/