1.mysql內實現rownum
SELECT
@rownum := @rownum +1 AS rownum,
e.*
FROM
(SELECT
@rownum := 0) r,
employee e
2.獲取出重複的記錄,保留最新一條
SELECT a.createTime,a.userId FROM short_video_entity a
LEFT JOIN short_video_entity b ON a.userId = b.userId
AND a.createTime < b.createTime
GROUP BY a.createTime, a.userId
HAVING count(b.id) < 1