delete from score where scoreId in(
SELECT t.scoreId from (
select sc.scoreId as scoreId from score sc
where (sc.examCode,sc.studentId) in
(select s.examCode,s.studentId from score s LEFT JOIN exam_manage em on em.examCode=s.examCode
WHERE em.type='1' and s.etScore >= em.passScore group by s.examCode,s.studentId having count(*)> 1 )
and sc.scoreId in ( select max(s1.scoreId) from score s1 LEFT JOIN exam_manage em on em.examCode=s1.examCode
WHERE em.type='1' and s1.etScore >= em.passScore group by s1.examCode,s1.studentId having count(*)> 1 ) ) t
//此方法执行一次只能去除一个重复的
)
mysql两张表中去除重复数据
最新推荐文章于 2024-04-16 13:41:20 发布