I have a db with domains.
I need to pull the domains suffixes and create a list of those suffixes. (.com, .net, .org …)
I’ve found that regexp patterns may help me. The only thing I can’t make is to filter those domains based on the pattern + uniqueness, in order to get my list.
Here’s my query:
$qry="select * from domain where domain_name REGEXP '[[.period.]][a-z]+'";
How should I add the unique criteria to it?
Thank you.
UPDATE:
Here’s the working query:
SELECT DISTINCT SUBSTRING_INDEX(domain_name, '.', -1) FROM domains WHERE domain_name REGEXP '[[.period.]][a-z]+'
MySQL has no construct to substitute using regular expressions, or to access matching groups. So regular expressions likely won’t help you. Perhaps the
SUBSTRING_INDEXfunction is more useful for you, as you can use that to extract the part after the final dot, using