Read only
Every query below is a SELECT. It changes nothing. Run it in phpMyAdmin or the mysql client, on a copy of the database if you have one.
WHMCS guide
One person on two accounts means split invoices, credit sitting on the account nobody opens and a support history in two places. Comparing e-mail addresses as typed misses much of it: on one of our own installs that comparison finds nothing, while ignoring Gmail dots and +tags finds over 100 groups to review.
DMS.S2 — Before you start
Every query below is a SELECT. It changes nothing. Run it in phpMyAdmin or the mysql client, on a copy of the database if you have one.
A family or an office can share a phone or a mailbox. Open both accounts before you decide they are one client.
Take a database backup first, and check services, open invoices and credit on both accounts.
DMS.S3 — The queries
Ignores capital letters and stray spaces.
SELECT LOWER(TRIM(email)) AS mailbox, GROUP_CONCAT(id ORDER BY id) AS client_ids
FROM tblclients
GROUP BY mailbox
HAVING COUNT(*) > 1;
Gmail delivers j.doe+host@gmail.com and jdoe@gmail.com to the same person.
SELECT REPLACE(SUBSTRING_INDEX(SUBSTRING_INDEX(LOWER(TRIM(email)), '@', 1), '+', 1), '.', '') AS inbox,
GROUP_CONCAT(id ORDER BY id) AS client_ids
FROM tblclients
WHERE LOWER(TRIM(email)) LIKE '%@gmail.com'
GROUP BY inbox
HAVING COUNT(*) > 1;
Ignores dots, dashes and slashes. REGEXP_REPLACE needs MySQL 8 or MariaDB 10.
SELECT REGEXP_REPLACE(UPPER(tax_id), '[^A-Z0-9]', '') AS tax,
GROUP_CONCAT(id ORDER BY id) AS client_ids
FROM tblclients
GROUP BY tax
HAVING tax <> '' AND COUNT(*) > 1;
Compares the last 10 digits, so a country code does not hide the match.
SELECT RIGHT(REGEXP_REPLACE(phonenumber, '[^0-9]', ''), 10) AS phone, LOWER(TRIM(lastname)) AS surname,
GROUP_CONCAT(id ORDER BY id) AS client_ids
FROM tblclients
GROUP BY phone, surname
HAVING CHAR_LENGTH(phone) >= 8 AND COUNT(*) > 1;
DMS.S4 — The addon
Brasa Duplicate Clients runs these comparisons and more, shows what each account holds and which one to keep, and e-mails admins when a new group appears. It never merges anything.

$39 per year
Finds the accounts that look like the same person or company, so you can merge the right ones.
DMS.S5 — Questions
Open the account you want to remove, click Merge Clients Accounts on its Summary tab and enter the ID of the account to keep. The merge cannot be undone.
Usually the one with the active services and the payment history. Check open invoices and credit on both before merging.
DMS.S6 — Start a project
Tell us how the two accounts differ. If other hosts would hit it, it may become a check.