Extract domain name from email id
Question
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
It will take less than 1 minute to register for lifetime. Bonus Tip - We don't send OTP to your email id Make Sure to use your own email id for free books and giveaways
Answers ( 7 )
‘[email protected]’.split(“@”)[1].split(“.”)[0]
output->domain
Where email is the column containing email id’s in the form of ‘[email protected]’ and domain is the table name (PGSQL)
SELECT email,split_part(split_part(email,’@’,2),’.’,1)
FROM domain;
SELECT ID,
SUBSTRING ([Email], CHARINDEX( ‘@’, [Email]) + 1,
LEN([Email])) AS [answer]
FROM email
SELECT substring(email, CHARINDEX( ‘@’, [email]) + 1,
LEN([email])) AS [Domain]
From T;
Using ‘mail’ as the column containing the email and ‘table’ as the table/
select substr(email, charindex(‘@’,email)+1, len(email)) as domain_name
from table
Assuming the column of email ids as email_id and table name is customers
SELECT email_id, split_part(email_id, ‘@’, 2) AS Domain
FROM customers;
Suppose we have two columns ‘ID’ and ‘Email’ in a table named ‘mail’. We need to extract the domain name from the mail ids.
The following command can be used for the same.
SELECT ( SUBSTRING_INDEX ( SUBSTR( Email, INSTR ( Email,’@’ ) + 1 ) ) , ‘.’ ,1) as Domain_name from mail ;
INSTR(str1, str2) searches for str2 in str1 and gives the first position at which str1 occurs. ! has been added to t so that a position after the ‘@’ sign starts.
SUBSTR( str, position) gives a substring of str starting from the inputted position.
SUBSTRING_INDEX (str, delimiter, count) gives the substring from string str until the ‘count’ number of delimiter is seen.