Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT contacts.id
- FROM contacts
- INNER JOIN (
- SELECT first_name, last_name, count(*) AS rows
- FROM contacts
- WHERE deleted = 0
- GROUP BY SOUNDEX(first_name), SOUNDEX(last_name)
- HAVING count(rows) > 1
- ) AS p
- WHERE contacts.deleted = 0
- AND p.first_name SOUNDS LIKE contacts.first_name
- AND p.last_name SOUNDS LIKE contacts.last_name
- ORDER BY contacts.date_entered DESC
- [...] AND SOUNDEX(p.first_name) = SOUNDEX(contacts.first_name) [...]
- SELECT c1.id as contact_id,
- c2.id as similar_id
- FROM contacts c1
- JOIN contacts c2
- ON c2.id <> c1.id
- AND c2.deleted = 0
- AND SOUNDEX(c2.first_name) = SOUNDEX(c1.first_name)
- AND SOUNDEX(c2.last_name) = SOUNDEX(c1.last_name)
- WHERE c1.deleted = 0
- ORDER BY c1.date_entered DESC
- SELECT c1.id as contact_id,
- c2.id as similar_id
- FROM contacts c1
- JOIN contacts c2
- ON c2.id <> c1.id
- AND c2.deleted = 0
- AND c2.first_name_soundex = c1.first_name_soundex
- AND c2.last_name_soundex = c1.last_name_soundex
- WHERE c1.deleted = 0
- ORDER BY c1.date_entered DESC
- SELECT SOUNDEX('cholmondley');
- +------------------------+
- | SOUNDEX('cholmondley') |
- +------------------------+
- | C4534 |
- +------------------------+
- SELECT SOUNDEX('chumleigh');
- +----------------------+
- | SOUNDEX('chumleigh') |
- +----------------------+
- | C542 |
- +----------------------+
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement