开发者

Delete all rows except recent two entries for each member

I have a table where member_id gets inserted for different user. I want to delete the entries of member_id except recent two entries for each member in the table.

Tell me the optimized way because it's a very large table.

i.e. table should开发者_运维知识库 have 2 recent entries for each member.

I need query in mysql 4.X.X.X


$recent = $this->db->insert_id();
$sql = delete from tbl_manager where sno<$recent-2;
$this->db->query();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜