mysql 删除重复项sql语句
我的sql 代码:SELECT v.iId, v.iNo, v.vTitle, l.vTitle AS lesson, h.cDate FROM user_video_history h
JOIN biz_video v ON h.iVideoId=v.iId JOIN biz_lesson l ON v.iLessonId=l.iId
WHERE h.vUserCode='1000563' GROUP BY vTitle , cDate DESC LIMIT 0, 20
首先我对日期进行了倒序,显示最新的,但是我想删除重复的题目,试了很多办法,没成功
delete A
from tb A,tb B
where A.ino=B.ino and A.vtitle=B.vtitle and A.lesson=B.lesson and A.cDate>B.cDate;
select *
from (
SELECT v.iId, v.iNo, v.vTitle, l.vTitle AS lesson, h.cDate FROM user_video_history h
JOIN biz_video v ON h.iVideoId=v.iId JOIN biz_lesson l ON v.iLessonId=l.iId
WHERE h.vUserCode='1000563' GROUP BY vTitle , cDate DESC LIMIT 0, 20
) t group by vTitle