Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Quick way to check for duplicate records?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00783217
Message ID:
00783219
Vues:
16
Take a look at this message someone sent to my mail.


FINDING DUPLICATE RECORDS

Sometimes it is important to identify duplicated records in a table.
For
example, you might have a mailing list and you want to make sure you
don't
have the same customer in it more than once. So how do you find the
duplicates? One way is to write a program that steps through the table
one
record at a time and for each record scan the rest of the table.
However,
there is an easier and more efficient approach using SQL:

SELECT first_name + last_name ;
FROM cust_table ;
GROUP BY first_name + last_name ;
HAVING COUNT(first_name + last_name) > 1

What if you want to see each of the records that has a duplicate
instead of
just a list of names that are duplicated? Here is an example:

SELECT *;
FROM cust_table ;
WHERE first_name + last_name in ;
(SELECT first_name + last_name ;
FROM cust_table ;
GROUP by first_name + last_name ;
HAVING COUNT(first_name + last_name) > 1);
INTO CURSOR duplicates

*~*~*~*~*~*~*~*~*



Release 2 of Foxy Classes is currently under way. There are a number
of
excellent classes planned, including an end-user data import wizard
with its
own builder, a blazing fast moverslist class based on grids instead of
list
boxes, and much more. However, you don't have to wait for version 2 to
enjoy the benefits of Foxy Classes. Order any time between now and the
second release date and you will get a free upgrade to release 2 when
it is
out! Just mention the free upgrade offer when you place your order.

Visit Foxy Classes at http://www.foxyclasses.com today and check out
the
sample application. Remember, Foxy Classes is the easiest way to
enhance
your existing or new Visual FoxPro applications.


>I am looking at a client's data set and I am unable to set an index tag as a primary key because there is a uniqueness violation.
>
>The key is made up of: systemdealnumber+systemaccounttype
>
>Is there a quick SELECT statement I could run that would tell me which records in the table are the duplicates? For some reason I'm drawing a blank on this..
>
>Laterness,
>Jon
Dominican Republic, a Paradise in America
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform