I am very new to MySQL, I am trying to make an events page that counts and displays likes. I get the error:
Error details: SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #10 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'db.events_likes.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by I cannot change SQL mode, so I was wondering if there was a way to aggregate the column?
code:
SELECT *, eventid, COUNT(events_likes.id) AS likes, GROUP_CONCAT(users.fname SEPARATOR '|') AS liked_by FROM events LEFT JOIN events_likes ON events.eventid = events_likes.event LEFT JOIN users ON events_likes.user = users.id GROUP BY events.eventid https://stackoverflow.com/questions/66937416/non-aggregated-column-with-count April 04, 2021 at 10:02AM
没有评论:
发表评论