gpt4 book ai didi

mysql - 添加列的 Group_concat

转载 作者:行者123 更新时间:2023-11-29 10:41:23 25 4
gpt4 key购买 nike

我得到了一个运行良好的查询:

SELECT Course, Period, Room, Location, TeacherId, GROUP_CONCAT(StudentId) as Students 
FROM cursosv2
GROUP BY Course, Period, Room, Location, TeacherID;

我想要的(也许太基本了)是在结果查询中拥有一个新列,例如带有 period+room+'final' 联接值的 NEW COLUMN A。但我不断遇到异常(exception)。不知道真正的原因。

我在尝试什么...

SELECT Course, Period, Room, Period+' '+Room+' Final' as test, Location, TeacherId, GROUP_CONCAT(StudentId) as Students 
FROM cursosv2
GROUP BY Course, Period, Room, Location, TeacherID;

谢谢。

最佳答案

您还应该使用 concat 进行字符串连接(而不是 + )并添加到分组依据

 SELECT Course, Period, Room, concat( Period,' ',Room,' Final') as test, Location, TeacherId, GROUP_CONCAT(StudentId) as Students 

FROM cursosv2
GROUP BY Course, Period, test, Room, Location, TeacherID;

关于mysql - 添加列的 Group_concat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45421482/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com