Update get safe rated images query for MySQL 5.7.5
Update get safe rated images query for MySQL 5.7.5

MySQL 5.7.5 enables by default the sql_mode=only_full_group_by option
which only allows GROUP BY queries that are compatible with the SQL
standard.

See: https://dev.mysql.com/doc/refman/5.7/en/group-by-handling.html

This commit changes the query to conform to the standard while still
producing the same results as the old query.

kusubooru/shimmie