Get domain name from Email in Oracle SQL

How to get domain name from given email id in Oracle SQL (or) PL/SQL

Very easy to get domain name from mail id like ‘thamaraiapex@gmail.com’ => gmail

SELECT

(substr(substr(‘thamaraiapex@gmail.com’, instr(‘thamaraiapex@gmail.com’, ‘@’) + 1), 1,

instr(substr(‘thamaraiapex@gmail.com’, instr(‘thamaraiapex@gmail.com’, ‘@’) + 1), ‘.’) – 1)) as domain_name

FROM dual;

Result:-

gmail

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s