Mysql多记录同一字段拼接到一个字段 或 查询两字段包含

字段拼接GROUP_CONCAT
SELECT class_code,GROUP_CONCAT(distinct teacher_code),GROUP_CONCAT(distinct teacher_name),sum(lessons_hours) lesson_hours FROM
biz_teach_class_info_detail group by class_code

查询new_teach_code包含teach_code的记录
select teach_name,new_teach_name from long_to_short where FIND_IN_SET(teach_code,new_teach_code);

你可能感兴趣的:(Mysql多记录同一字段拼接到一个字段 或 查询两字段包含)