DELETE t1 FROM sys_user_password_history AS t1 LEFT JOIN ( SELECT id FROM sys_user_password_history WHERE user_id = #{userId} ORDER BY create_time DESC LIMIT #{count} ) AS t2 ON t2.id = t1.id WHERE t2.id IS NULL