php - Can not group by when creating json encode on CodeIgniter -


i'm trying make encode json mysql database , join table codeigniter want combine typing same data 1 group_by error occurred. wrong?

error alert

expression #1 of select list not in group clause , contains nonaggregated column 'project.mytb1.id' not functionally dependent on columns in group clause; incompatible sql_mode=only_full_group_by

my script

function get_idcode() {     $keyword = $this->uri->segment(3);     $data = $this->db->from('mytb1')                           ->join('mytb2', 'mytb2.id = mytb1.id')                               ->like('mytb1.id',$keyword)                           ->group_by('mytb1.id')                                                     ->get();        foreach($data->result_array() $row)     {         $arr['query'] = $keyword;         $arr['suggestions'][] = array(             'value' =>$row->id,             'name'  =>$row->name          );     }     echo json_encode($arr); }    

try this

$data = $this->db->select('*') # added                     ->from('mytb1')  # changed                     ->join('mytb2', 'mytb2.id = mytb1.id')                       ->like('mytb1.id',$keyword)                   ->group_by('mytb1.id')                                             ->order_by('mytb1.id', 'asc') # added                                          ->get();  

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -