QUERY
SELECT g.id, g.name, p.photo, p.description, p.name AS photo_name, p.id AS photo_id, ( SELECT count(id) FROM cv_photos WHERE gallery = g.id ) as photo_count FROM cv_photos_galleries AS g LEFT JOIN cv_photos AS p ON p.gallery = g.id WHERE p.gallery_cover = 1 GROUP BY g.id ORDER BY name ASC

ERROR
1055: Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'cncostru_db.p.photo' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by