Home > Database > Mysql Tutorial > body text

删除重复的记录,并保存第一条记录或保存最后一条记录

WBOY
Release: 2016-06-07 17:56:49
Original
961 people have browsed it

删除重复的记录,并保存第一条记录或保存最后一条记录

删除表:dgpage中Mail重复的记录并保留最后一条.
delete dgpage where id in ( select a.id from dgpage a, dgpage b where a.mail = b.mail and a.id > b.id )


删除表:dgpage中Mail重复的记录并保留最近一条.
delete dgpage where id in ( select a.id from dgpage a, dgpage b where a.mail = b.mail and a.id
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!