mysql去除表中重复数据(保留最小或者保留最大id数据)

-- 删除重复留最小
DELETE t1
FROM
	ct_course_info t1
INNER JOIN ct_course_info t2
WHERE
	t1.id > t2.id
AND t1.`name` = t2.`name`
-- 删除重复留最大
DELETE t1
FROM
	ct_course_info t1
INNER JOIN ct_course_info t2
WHERE
	t1.id < t2.id
AND t1.`name` = t2.`name`

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