I got this error when I used GROUP BY in the query below
Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'table_name.total_ttc' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by in ............
function situationsList(){
$query = "SELECT `ref_s`, `total_ttc`, `created_at`, `mode_pay` FROM `situations` GROUP BY ref_s ";
$statement = $GLOBALS['PDO']->prepare($query);
$statement->execute();
$data = array();
while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
$data[] = $row;
}
return json_encode($data);
}
The query works just fine in localhost but when I upload it on server I get that error!