If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Compare Two Duplicate records

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-09-09, 03:52
riddhi riddhi is offline
Registered User
 
Join Date: Jul 2009
Posts: 4
Question Compare Two Duplicate records

Hello All,

It's Very urgent for me !!!!

Problem Description :

I have two table 1) user 2) userInfo
I want to Find Duplicate user, For that I write one Query is
SELECT ub.userId, ub.username, COUNT(ub.username) AS userInfo_NumOccurrences
FROM userinfo AS ub
GROUP BY ub.username, ub.AffiId
HAVING (COUNT(ub.username) > 1) ;

Its Showing Two duplicate username but Also i want compare affId of duplicate users For Example :

user table | userInfo table
user.username = userInfo.username
user.affId = userInfo.affId

If Both are Same then n then it will be consider as duplicate records

So how can i write query for that ? ? ? ?? ? ?? Or any modificationon above query ????
Reply With Quote
  #2 (permalink)  
Old 09-09-09, 08:11
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
please do a SHOW CREATE TABLE for both tables
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 09-09-09, 08:16
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
please do a SHOW CREATE TABLE for both tables
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #4 (permalink)  
Old 09-09-09, 23:54
mnirwan mnirwan is offline
Registered User
 
Join Date: Sep 2009
Posts: 64
I'm assuming duplicate user means username with affid that exists in both tables. If that's the case,

SELECT username, affid, count(*) FROM (
SELECT username, affid FROM user
UNION ALL
SELECT username, affid FROM userInfo
) AS all users
GROUP BY 1, 2
HAVING COUNT(*) > 1
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On