I have two tables ( user and log ), and would like to list the users by sorting by the last logged in. I'm using GROUP BY
to join the logs (since a user can have more than one).
The problem occurs when I add the ORDER BY
, returning error in the query:
Expression # 2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'insidetv.log.data' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode = only_full_group_by
SQL:
SELECT nome, log.data FROM usuario JOIN log ON usuario.codigo = log.codigo_usuario GROUP BY usuario.codigo ORDER BY log.data