【发布时间】:2015-09-12 10:15:02
【问题描述】:
这是我的桌子:
placeID | name | time
如果 placeID 在表中的记录超过 3 条,我的目标是删除最旧的记录。
很难理解,举个例子就明白了:
1 | "Some Name" | *fresher timestamp*
1 | "Some Name" | *fresher timestamp*
1 | "Some Name" | *older timestamp* -- > Delete this result since there are more than 3 records, and this is the older than the rest
1 | "Some Name" | *older timestamp* -- > Delete this result since there are more than 3 records, and this is older than the rest
1 | "Some Name" | *fresher timestamp*
2 | "Some Name" | *fresher timestamp*
2 | "Some Name" | *fresher timestamp*
我的麻烦:我如何为每个在我的表中有超过 3 条记录的 placeID 循环?
删除最旧的结果不会有问题。
我尝试了什么:
SELECT placeID,COUNT(placeID) FROM place_fbStatus WHERE count(placeID) > 3
错误:#1111 - 组函数的使用无效
再试一次:
SELECT id, placeID
FROM place_fbStatus
HAVING COUNT( placeID ) >4
LIMIT 0 , 30
问题:只显示一个placeID
【问题讨论】:
标签: mysql