Re: Finding almost duplicate rows in mysql
From: Chung Leong (chernyshevsky_at_hotmail.com)
Date: 01/10/04
- Next message: Yang Li Ke: "Re: [code] Re: form tags?"
- Previous message: Russell: "Finding almost duplicate rows in mysql"
- In reply to: Russell: "Finding almost duplicate rows in mysql"
- Next in thread: Russell: "Re: Finding almost duplicate rows in mysql"
- Reply: Russell: "Re: Finding almost duplicate rows in mysql"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 10 Jan 2004 12:13:42 -0500
The query should be like this, I think:
SELECT userID, COUNT(*)
FROM users
GROUP BY userID
ORDER BY userID
HAVING COUNT(*) > 1;
Uzytkownik "Russell" <null@null.noemail> napisal w wiadomosci
news:DYVLb.11333$6L3.10494@news-binary.blueyonder.co.uk...
> I'm using MySQL 4.1.1
>
> I've inherited a database which has some (almost) duplicate rows.
>
> The databse is like this.
>
> userID
> userPosition
> userDepartment
>
> No user should be in more than one department but some are. I need to
> find all the users who are listed in more than one department for manual
> fixing.
>
> I can do something like
>
> SELECT *, COUNT(userID)
> FROM users
> GROUP BY COUNT(userID)
> ORDER BY COUNT(userID) DESC
>
> But that still gives me all 10,000 rows. All I want is where
> COUNT(userID) > 1
>
> If I add a WHERE clause to that effect I just get error messages.
>
> Any suggestions?
>
- Next message: Yang Li Ke: "Re: [code] Re: form tags?"
- Previous message: Russell: "Finding almost duplicate rows in mysql"
- In reply to: Russell: "Finding almost duplicate rows in mysql"
- Next in thread: Russell: "Re: Finding almost duplicate rows in mysql"
- Reply: Russell: "Re: Finding almost duplicate rows in mysql"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|