我有一个旧的 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 is not in GROUP BY
我怎样才能重写这个工作的查询?当我采用 GROUP BY 中的所有字段时,它可以工作。但是我可以在动态表中添加字段,这样我就无法列出 Group By 中的所有字段。
谢谢你的帮助