我有一个旧的SQL查询:
SELECT
GROUP_CONCAT(DISTINCT groups.groupID ORDER BY groups.groupID ASC SEPARATOR ',') AS groupIDs,
GROUP_CONCAT(DISTINCT languages.languageID ORDER BY languages.languageID ASC SEPARATOR ',') AS languageIDs,
user_option.*, user.*
FROM user user
LEFT JOIN user_to_groups groups ON (groups.userID = user.userID)
LEFT JOIN user_to_languages languages ON (languages.userID = user.userID)
LEFT JOIN user_option_value user_option ON (user_option.userID = user.userID)
WHERE user.userID = 1 GROUP BY user.userID
在新服务器上,我收到此错误: 1055 user.fieldName不在GROUP BY
中如何重写此查询,这项工作?当我在GROUP BY中使用所有字段时,它可以工作。但我可以在表格动态中添加字段,这样我就无法列出分组依据中的所有字段。
感谢您的帮助