Solved

I need to delete duplicated companies

Posted on 2013-01-14
1
207 Views
Last Modified: 2013-01-14
Hello,

During many imports my customer imported  the same companies many times.

e.g.

Company 1
Company 2
Company 3
Company 1
Company 2
Company 3
Company 2
Company 3
Company 3

I need to delete them so as only the last should remain from each company instance.
I have a timestamp in the table.

The desired result would be
Company 1
Company 2
Company 3

Thank you in advance
0
Comment
Question by:starhu
1 Comment
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 500 total points
ID: 38773753
try this


 

DELETE n1 FROM Company_table n1, Company_table n2 WHERE n1.date_field > n2.date_field AND n1.company_name = n2.company_name

refer
http://stackoverflow.com/questions/4685173/delete-all-duplicate-rows-except-for-one-in-mysql

if any problem share the sample data and column names
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Creating and Managing Databases with phpMyAdmin in cPanel.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question