Heim  >  Artikel  >  Backend-Entwicklung  >  sql语句删除数据表重复字段的方法,sql语句_PHP教程

sql语句删除数据表重复字段的方法,sql语句_PHP教程

WBOY
WBOYOriginal
2016-07-13 10:08:071133Durchsuche

sql语句删除数据表重复字段的方法,sql语句

 大家都可能遇到字段重复的情况,网上很多人在找方法,也给出了一些方法,但是有的方法是误导大家,铁牛写出以下方法,方便大家使用

  1.通过group by把重复的字段筛选出来,并建立临时表tmp

create table tmp as select max(id) as col1 from www group by dfdfd;

  2.从去重表对象里通过not in的条件来筛选出不在临时表的列col1,执行not in的删除操作

delete from www where id not in (select col1 from tmp); 

  3.删除临时表

drop table tmp;

  欢迎加入PHP技术和职场交流群:383730534

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/952777.htmlTechArticlesql语句删除数据表重复字段的方法,sql语句 大家都可能遇到字段重复的情况,网上很多人在找方法,也给出了一些方法,但是有的方法是误...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn