codeigniter distinct
You can use the following CodeIgniter code to retrieve distinct values from a database:
$this->db->distinct();
$this->db->select('column_name');
$query = $this->db->get('table_name');
Explanation:
1. $this->db->distinct();
- This code sets the query to retrieve distinct values from the specified column.
$this->db->select('column_name');
- This line selects the specific column from which you want to retrieve distinct values.$query = $this->db->get('table_name');
- This code executes the query to retrieve distinct values from the specified column in the specified table. The result will be stored in the$query
variable for further processing.