How to quickly delete Repeated Records of specified fields in access

Source: Internet
Author: User
How to quickly delete Repeated Records of access fields Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiDB/html/delphi_20061223120244146.html
I have an access data table as follows:
ID name score
1. Old Zhang 80
2 Wang erxiao 70
3. Old Zhang 80
4 Li xiao 90
================================
Now I want to delete records with duplicate field names to achieve the following results:
ID name score
1. Old Zhang 80
2 Wang erxiao 70
4 Li xiao 90

How can access be operated in Delphi as quickly as possible?
I checked csdn and saw a person using the expression"

This is recognized as the fastest SQL statement for deleting duplicate records:

Delete from EMP e where E. rowid> (select Min (X. rowid) from emp x where X. emp_no = E. emp_no );"

What should I do as quickly as possible?

Please provide ideas

There seems to be no good way to solve this problem,
Do this,
Function getdelreocrdsid: string;
VaR
Midstr, resultstr: string;
Begin
With adodataset do
Begin
If active then active: = false;
Commandtext: = 'select * from EMP order by [name] ASC '; // be sure to sort
Open; midstr: = ''; resultstr: = '';
While (not EOF) Do
Begin
If trim (midstr) = trim (fieldbyname ('name'). asstring) then
Resultstr: = resultstr + fieldbyname ('id'). asstring + ',';
Else midstr: = fieldbyname ('name'). asstring;
Next;
End;
If result <> ''then
Result: = copy (resultstr1, length (resultstr)-1)
Else result: = '-1'
Close;
End;
End;

Procedure deleteselectrecord;
Begin
With adocommand do
Begin
Commandtext: = 'delete from EMP where ID in ('+ getdelreocrdsid + ')';
Execute;
End;
End;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.