MySQL Forums
Forum List  »  New in 4.1: Subqueries

Problem with "Find Duplicates" using subquery
Posted by: Michael Berkowitz
Date: March 16, 2005 12:12PM

Hello,

I'm using Version 4.1.10-Debian_1.

Here's the query I'm running:

select * from Donations where Donation_id in
(SELECT Donation_id FROM Donations group by date, amt, donor having count(*) > 1)

The idea is to find all the Donations records that have the same date, amt and donor as one-or-more other records -- in short, a "Find Duplicates" query.

The logic of the query is to first find the primary keys ('Donation_id') of these records in a subquery, then retrieve all the other fields for those records. The subquery works fine when I run it by itself.

The server accepts the syntax of the full query and runs it, but it just spins its wheels and never returns; I mean, I let it run long enough that if it were going to return, it would have. Doing a "show processlist" shows the state of the process running this query as "Copying to tmp table".

I'd appreciate any insight anyone can give me.

TIA

Michael

Options: ReplyQuote


Subject
Views
Written By
Posted
Problem with "Find Duplicates" using subquery
7556
March 16, 2005 12:12PM


Sorry, you can't reply to this topic. It has been closed.
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.