目录
一、会议通知查询SQL
登录xx账号,就要查出凡是xx是参与者、列席者、主持人中的其中一员,那么都需要查询出来
最终要查询出来的结果
分析(涉及到的表):
会议信息表:t_oa_meeting_info
会议反馈表:t_oa_meeting_feedback
查询出带有admin id=5 的会议信息:
SELECT * from t_oa_meeting_info where FIND_IN_SET (2,CONCAT(canyuze,',',liexize,',',zhuchiren))
运行SQL结果:
每一条都带有id = 5
不管会议是否得到反馈,都要查询出来,所以选外连接,会议信息表为主:
SELECT IFNULL(f.result,-1) result,t1.* FROM (SELECT * from t_oa_meeting_info where FIND_IN_SET(2,CONCAT(canyuze,',',liexize,',',zhuchiren)) and state=4) t1 LEFT JOIN t_oa_meeting_feedback f on t1.id=f.meetingId and f.personId=5 ORDER BY result;
运行结果(共九条数据):
二、会议反馈详情SQL
分析(涉及到的表):
用户表:t_oa_user
会议信息表:t_oa_meeting_info
会议反馈表:t_oa_meeting_feedback
查询条件:会议 id 12
拿到会议 id 为12的会议,所有参与人员的姓名
先拿到所有的参与人员 id
SELECT CONCAT(canyuze,',',liexize,',',zhuchiren) from t_oa_meeting_info where id=12
SQL运行结果:
2) 再拿到对应参与人员的姓名
SELECT * from t_oa_user where FIND_IN_SET(id,(SELECT CONCAT(canyuze,',',liexize,',',zhuchiren) from t_oa_meeting_info where id=12))
连接 会议信息反馈表,拿到对应的反馈情况(未读、参加、不参加)
SELECT * from t_oa_user where FIND_IN_SET(id, (SELECT CONCAT(canyuze,',',liexize,',',zhuchiren) from t_oa_meeting_info where id=12))
根据 会议信息反馈情况进行分组
select t.result,GROUP_CONCAT(t.name) names from (select t1.name,IFNULL(f.result,-1) result from (SELECT * from t_oa_user where FIND_IN_SET(id, (SELECT CONCAT(canyuze,',',liexize,',',zhuchiren) from t_oa_meeting_info where id=12))) t1 left join t_oa_meeting_feedback f on t1.id=f.personId and f.meetingId=12) t GROUP BY t.result