I have an array $DeptID :array(5) { [0]=> string(1) "2" [1]=> string(1) "8" [2]=> string(2) "11" [3]=> string(2) "15" [4]=> string(2) "17" }
Then, I want to select from MySQL database to get data where DeptID in array. My query:
$DeptdID = implode(',', $DeptID);
$this->db->select(*)
->from('tabel_data')
->where('DeptID IN ('.$DeptID.')')
->group_by('DeptID', 'ASC')
->get(''):
But an error occur.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near (Array) GROUP BY `DeptID` at line 6.
Maybe someone can give me a solution
whereclause. Try referencing$DeptdIDin yourwhere()or change$DeptdIDto$DeptIDin your first line.