mysql重复数据表仅取的最新记录

1.SQL模板

SELECT
	t1.重复列,
	t1.时间列,
	t1.其余列 
FROM
	表 t1
	INNER JOIN ( SELECT t2.重复列, max( t2.时间列 ) AS 时间列 FROM 表 t2 GROUP BY t2.重复列 ) AS t3
	ON t1.重复列 = t3.重复列 AND t1.时间列 = t3.时间列
	GROUP BY t1.重复列
SELECT
	t1.USER_ID,
	t1.last_updated_date,
	t1.ID,
	t1.problems 
FROM
	t_iov_help_feedback t1
	INNER JOIN ( SELECT t2.USER_ID, max( t2.last_updated_date ) AS last_updated_date FROM t_iov_help_feedback t2 GROUP BY t2.USER_ID ) AS t3 
	ON t1.USER_ID = t3.USER_ID AND t1.last_updated_date = t3.last_updated_date
	GROUP BY t1.USER_ID;

mysql重复数据表仅取的最新记录_第1张图片

你可能感兴趣的:(数据库,sql,数据库,database)