I currently have a customers table that has duplicate customers in it. I want to select a unique list of customers, with no duplicates of home phone OR cell phone.
So, if any customer has the same home phone or cell phone as another customer then, I want to not return that customer from the query.
One caveat — if homephone or cellphone is empty, then I obviously do not want to count it in the anti-duplicate logic, because some customers only have a homephone, or only have a cellphone.
Here is the current query that I have, which returns unique rows for homephone AND cellphone.
SELECT id, firstname, lastname, homephone, cellphone, city, state, zip,
country, FROM customers WHERE (homephone != "" OR cellphone != "")
GROUP BY homephone, cellphone
Any ideas? Thanks.
You have to funnel all phone numbers into the one evaluation and sort/group by that.
Try this:
It will get the first row found for every unique value of “homephone, but if blank then cellphone”