Skip to content

Commit

Permalink
Fix MySQL 5.7.5+ error due to ONLY_FULL_GROUP_BY mode: use MIN()
Browse files Browse the repository at this point in the history
SELECT list is not in GROUP BY clause and contains nonaggregated column...
incompatible with sql_mode=only_full_group_by

https://stackoverflow.com/questions/41887460/select-list-is-not-in-group-by-clause-and-contains-nonaggregated-column-inc
https://dev.mysql.com/doc/refman/8.0/en/group-by-handling.html

Note: MariaDB does not enable the ONLY_FULL_GROUP_BY mode by default
  • Loading branch information
francoisjacquet committed Apr 24, 2024
1 parent ac87433 commit 154c90d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# CHANGES
## RosarioSIS Student Information System

Changes in 11.5.3
-----------------
- Fix MySQL 5.7.5+ error due to ONLY_FULL_GROUP_BY mode: use MIN() in Address.inc.php

Changes in 11.5.2
-----------------
- Fix get Student Info when Parent associated to various students in ReportCards.fnc.php
Expand Down
3 changes: 2 additions & 1 deletion modules/Students/includes/Address.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@
if ( $DatabaseType === 'mysql' )
{
// @since 10.0 Use GROUP BY instead of DISTINCT ON for MySQL
// @since 11.5.3 Fix MySQL 5.7.5+ error due to ONLY_FULL_GROUP_BY mode: use MIN()
DBQuery( "INSERT INTO students_join_people
(STUDENT_ID,PERSON_ID,ADDRESS_ID,CUSTODY,EMERGENCY,STUDENT_RELATION)
SELECT '" . UserStudentID() . "',PERSON_ID,
ADDRESS_ID,CUSTODY,EMERGENCY,STUDENT_RELATION
MIN(ADDRESS_ID),MIN(CUSTODY),MIN(EMERGENCY),MIN(STUDENT_RELATION)
FROM students_join_people
WHERE ADDRESS_ID='" . (int) $_REQUEST['address_id'] . "'
GROUP BY PERSON_ID" );
Expand Down

0 comments on commit 154c90d

Please sign in to comment.