Below is my model code, in which I'm getting a database error:
public function getxyz()
{
$query ='SELECT DISTINCT(LEFT(field1,LOCATE('-',field1) - 1)) as field1
FROM table1';
$res = $this->db->query($query);
return $res->result();
}
Note: This query is running successfully in phpmyadmin. Any help will be appreciated. Thanks in advance.