[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compare Tablets by Key1 and Remove Duplicates


Subqueries.

select * from ClientJune2005 where customerCode = (select customercode from ClientAug2005);

http://dev.mysql.com/doc/refman/4.1/en/subqueries.html

=C=
|
| Cal Evans
| http://www.calevans.com
|

VaioLord wrote:
I have just moved over to a new job and been given the task of trying to sort out historic client databases (MS-Access). I have exported everything to CSV, then into MySQL 5.0.15 no problems at all. However due to the way the original system was developed i have so much duplicated data it is crazy.

Can anyone point me in the right direction for a method to delete records based on a a field value if it also exists in another table.

ie.

Table "ClientJun2005" contains fields "customercode", "name", "address", "telephone", with the field "customercode" being the Unique Primary Key.

Table "ClientAug2005" contains fields "customercode", "name", "address", "telephone", with the field "customercode" being the Unique Primary Key.

What I need is to compare tables "ClientJun2005" and "ClientAug2005" by "customercode" when the this value exists in both databases delete one and leave one alone.

I know that it would be possible to do this with PHP but home that there is a simple MySQL method I can run direct of MySQL.

Hope someone can help me out.

Stephen



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.