I have a bunch of user accounts that I need to create associations with based on DOB postcode etc.
I have the following query:
SELECT DISTINCT CONCAT_WS(' , ' ,a.user_id , GROUP_CONCAT( b.user_id SEPARATOR ' , ' ) )
FROM tbl_users_details a,
tbl_users_details b
WHERE a.user_id != b.user_id
AND a.date_of_birth = b.date_of_birth
AND a.postcode = b.postcode
AND LEVENSHTEIN_RATIO( a.last_name , b.last_name ) > 60
GROUP BY a.user_id
To demonstrate my requirements...
If accounts 1 5 9 and 12 meet the criteria (ie these are the same people)
I will get 4 results in the format
1 , 5 , 9 , 12
5 , 1 , 9 , 12
9 , 1 , 5 , 12
12 , 1 , 5 , 9
I deally I'd like just 1,5,9,12
Any pointers would be great.
thanks people.