这种事情我干过,只能编程解决,基本思路就是设置循环,从第一个
记录
中取得几项数据(如厂名、编号等),并赋值,再根据所赋的值向下查找,找到以后说明该记录重复,就可以删除或者做
标记
,直到文件
末尾
。然后用skip命令跳到第二个记录,再这样进行一遍,直到结束。
进行这样的工作前最好进行
备份
,防止出现
错误
。再就是设置个
,比如命名为cfqk(重复情况,N型),用程序进行挑选时,就可以找到重复的记录时把cfqk标为1,用第二个记录进行查找时,就能根据该字段进行判断,如果cfqk<>1就根据第二个记录向下查找,如果是1说明它本身重复,再从第三个记录查起,依次类推,就能把所有重复的记录都找出来,再用一个命令把所有cfqk是1的都删除,问题也就解决了。
如果不能设置这样的程序就回话,把
字段名
和类型告诉我,我再帮你设计。应该不难解决的。
MySQL查询重复字段,及删除重复记录的方法
数据库中有个大表,需要查找其中的名字有重复的记录id,以便比较。如果仅仅是查找数据库中name不重复的字段,很容易:
SELECT min(`id`),`name` FROM `table` GROUP BY `name`;
但是这样并不能得到说有重复字段的id值。(只得到了最小的一个id值)查询哪些字段是重复的也容易:
SELECT `name`,count(`name`) as count FROM `table` GROUP BY `name` HAVING count(`name`) >1 ORDER BY count DESC;
但是要一次查询到重复字段的id值,就必须使用子查询了,于是使用下面的语句。
SELECT `id`,`name` FROM `table` WHERE `name` in (
SELECT `name`
FROM `table`
GROUP BY `name` HAVING count(`name`) >1);
但是这条语句在mysql中效率太差,感觉mysql并没有为子查询生成零时表。于是使用先建立零时表:
create table `tmptable` as (
SELECT `name`
FROM `table`
GROUP BY `name` HAVING count(`name`) >1);
用一个distinct
可以去重:
SELECT
distinct
t5FBillNo
AS
'订单编号',CONVERT(varchar(10)
,
t5FDate,120)
AS
'日期'
,
t4FName
AS
'客户名称',t6fallamount
AS
'订单金额'
,
t1fallamount
AS
'开票金额',
t2FDate
AS
'发票'
,
t3FPreAmountFor
AS
'预收款'
,
t3FAmountFor
AS
'现金',
t8FName
AS
'制单人'
,
t6FAmount-t3FPreAmountFor-t3FPreAmountFor
as
'余额'
,
t6FInterID
,
t4FItemID
FROM
ICSaleEntry
t1
,
ICSale
t2
,
t_RP_NewReceiveBill
t3,t_Organization
t4,SEOrder
t5,SEOrderEntry
t6,
--dbot_rp_Exchange
t7,dbot_User
t8,dbot_Department
t9,dbot_Currency
t10
where
t1FOrderInterID=t5FInterID
AND
t2FInterID=t1FInterID
AND
t5FInterID=t6FInterID
AND
t5FCustID=t4FItemID
AND
t3fexplanation=t2fnote
--AND
t3FBillID=t7FBillID
AND
t3FPreparer=t8FUserID
and
t9fitemId=t5FDeptID
and
t10FCurrencyID=t5FCurrencyID
AND
t5FInterID=t6FInterID
AND
t5FCustID=t4FItemID
sql查询去除重复值语句\x0d\sql 单表/多表查询去除重复记录\x0d\单表distinct\x0d\\x0d\多表group by\x0d\\x0d\group by 必须放在 order by 和 limit之前,不然会报错\x0d\\x0d\\x0d\\x0d\1、查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断\x0d\\x0d\select from people\x0d\\x0d\where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1)\x0d\2、删除表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断,只留有rowid最小的记录\x0d\\x0d\delete from people\x0d\where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1)\x0d\and rowid not in (select min(rowid) from people group by peopleId having count(peopleId )>1)\x0d\3、查找表中多余的重复记录(多个字段)\x0d\\x0d\select from vitae a\x0d\where (apeopleId,aseq) in (select peopleId,seq from vitae group by peopleId,seq having count() > 1)\x0d\4、删除表中多余的重复记录(多个字段),只留有rowid最小的记录\x0d\delete from vitae a\x0d\where (apeopleId,aseq) in (select peopleId,seq from vitae group by peopleId,seq having count() > 1)\x0d\and rowid not in (select min(rowid) from vitae group by peopleId,seq having count()>1)\x0d\5、查找表中多余的重复记录(多个字段),不包含rowid最小的记录\x0d\\x0d\select from vitae a\x0d\where (apeopleId,aseq) in (select peopleId,seq from vitae group by peopleId,seq having count() > 1)\x0d\and rowid not in (select min(rowid) from vitae group by peopleId,seq having count()>
以上就是关于foxpro数据库中如何删除重复记录全部的内容,包括:foxpro数据库中如何删除重复记录、怎么去除mysql字段中的重复值、sql去掉重复值等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)