This is an invalid aggregation. The results of a select should only contain the GROUP BY fields or an aggregate function over any other field. mysql/mariadb is lax without sql_mode=ONLY_FULL_GROUP_BY set. The results have chosen a different row for the class_id specified. The way these rows where inserted could result in a different set returned, for both mysql and mariadb. set sql_mode='ONLY_FULL_GROUP_BY' ref: https://mariadb.com/kb/en/library/sql-mode/ and do the query again. In short, its the query's problem for asking something non-specific. MySQL has changed this setting to the default in mysql-5.7.5. recommend #maria (or #mysql) freenode IRC channel for asking these kinds of questions. You'll get a faster response, especially if you have a follow up question. On 20/12/17 14:31, 落寞回头不如华丽转身 wrote: