如何从表中删除重复记录 [英] How to delete duplicate records from a table

查看:130
本文介绍了如何从表中删除重复记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

我想要一个可以删除重复记录的Visual foxpro 9.0中的代码。

I want a code in Visual foxpro 9.0 that can delete duplicate records.

详细

我有一个表名Mymaster。我想删除具有相同Taxapayer和相同Tax_office的记录,如下所示;

I have a table name Mymaster. I want to delete records that have the same Taxapayer and the same Tax_office as shown below;

例如; 2月10月有限公司有相同的tax_office。

for example; 2ND OCTOBER COMPANY LIMITED has the same tax_office.

  纳税人                                                              
Tax_office

 Taxpayer                                                           Tax_office

10月2日COMPANY LIMITED                        Osu

2月十月有限公司                         Osu

A& Ç购物中心                        &NBSP ;                        &NBSP ;          
Tema

A & C Mall                                                             Tema

A& Ç购物中心                        &NBSP ;                        &NBSP ;          
Adenta

A & C Mall                                                             Adenta

Fred Boateng                                                       
Makola

Fred Boateng                                                       
Makola

Gina Owusu                                                         
Nima

Gina Owusu                                                          
Nima

GRA                                                                        
Asokwa

GRA                                                                      Asokwa

GRA                                                                        
Adabraka

GRA                                                                      Adabraka

谢谢

推荐答案

假设您当前的表名为 TAXP

SELECT taxp
INDEX on taxpayer+tax_office tag taxp
SELECT taxpayer,tax_office, SUM(1) as ncount FROM taxp GROUP by taxpayer,tax_office INTO CURSOR c_taxCount
INDEX on taxpayer+tax_office tag taxp

SCAN FOR ncount > 1
  SELECT taxp
  SEEK c_taxCount.taxpayer+c_taxCount.tax_office 
  DELETE NEXT c_taxCount.nCount - 1
ENDSCAN 


这篇关于如何从表中删除重复记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆