Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Duplicates - Multiple fields
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01436141
Message ID:
01436144
Views:
81
This message has been marked as a message which has helped to the initial question of the thread.
>Hi Gang!
>
>I want to be able to find records in a table that have more than one field that is duplicate (last_name + first_name). We want to get rid of the duplicate fields (combine them together).
>
>So first, to find them....
>
>Is this code ok? To find all duplicate records on last_name + first_name ?
>
>
>SELECT last_name, first_name, alt_custno, paquinnumb FROM customer ;
>	WHERE last_name + " " + first_name IN ;
>		(SELECT last_name + " " + first_name AS cust_name FROM customer ;
>			GROUP BY last_name, first_name ;
>			HAVING count(last_name + " " + first_name) > 1);
>	ORDER BY last_name, first_name INTO CURSOR FINDDUPE
>
>
>
>Runs ok, but I want to be sure from others!
>
>Thanks!

The code is OK. You can also use a variation of it:
SELECT last_name, first_name, alt_custno, paquinnumb FROM customer ;
	inner join (select LastName, FirstName, count(*) as Dups from Customer group by LastName, FirstName having count(*) > 1) X
on Customer.LastName = X.LastName and Customer.FirstName = X.FirstName
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform