开发者

Delete all rows except recent two entries for each member

开发者 https://www.devze.com 2023-01-17 01:16 出处:网络
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.

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

精彩评论

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