我有以下查询,我正在努力。 我需要显示用户是谁(u.username)但是错误地获取了一个mysql完整组
select ass.client_id,
sum(ass.smsQuantity),
recent.created,
recent.createdBy,
sum(acc.credits) credits,
u.username
from accountSmsSubscriptions ass
left join sms_accounts acc on acc.client_id = ass.client_id
left join (select client_id,max(id) id from accountSmsSubscriptions group by client_id)
cur on cur.client_id = ass.client_id
left join accountSmsSubscriptions recent on recent.id = cur.id
left join users u on u.id = ass.createdBy
where ass.client_id = 242
group by ass.client_id
答案 0 :(得分:0)
错误告诉您在group by子句中包含所有非聚合列,即所有未加总的列。
它还表明sql_mode' ONLY_FULL_GROUP_BY'已在服务器上启用。这是一件好事,因为否则你会获得不确定的结果 - 所以不要禁用它!