<?php $this->db->distinct(); $this->db->select('accessid'); $this->db->where('record', $record); $query = $this->db->get('accesslog');