select `学号`,`姓名` from
(SELECT `学号`,`姓名`,group_concat(`成绩` order by `月份` SEPARATOR " ") as total from cj group by `学号`) as a
where left(total,6)='0 0 0 ' or right(total,6)=' 0 0 0' or instr(total,' 0 0 0 ')>0不知道行不行,效率低,还好数据比较少("连续三个月"比较麻烦)
(SELECT `学号`,`姓名`,group_concat(`成绩` order by `月份` SEPARATOR " ") as total from cj group by `学号`) as a
where left(total,6)='0 0 0 ' or right(total,6)=' 0 0 0' or instr(total,' 0 0 0 ')>0不知道行不行,效率低,还好数据比较少("连续三个月"比较麻烦)
并在月份上建索引。sql:
select * from cj as a,cj as b,cj as c where a.下月月份=b.月份 and b.下月月份=c.月份 and a.成绩=0 and b.成绩=0 and c.成绩=0;