[odb-users] MySQL 5.7 ORDER BY clause is not in SELECT list

Lukas Obermann obermann.lukas at gmail.com
Wed Nov 8 08:09:30 EST 2017


I have a big view which joins in a lot of tables and just return the id of the „main“ table. But, I need to order the response based on different values which are joined in. So I just append „ORDER BY „+column to the query.
Now, since MySQL 5.7 there was a constraint added that the field used in the order by must be present in the select list. So the query resulsts in following error:

3065 (HY000): Expression #1 of ORDER BY clause is not in SELECT list, references column 'common.fileView.lastPlayed_ulong_date' which is not in SELECT list; this is incompatible with DISTINCT

Is there a way to work around this without having to modify the mysql mode on the server? So to either dynamically add the field to the select list or is there a special call to use for ordering?
Of course I do not want to add all the fields to the select list as it would take forever to query then.


More information about the odb-users mailing list