In this article we will learn about some of the frequently asked MySQL programming questions in technical like “Get the User Name and Domain Name from an Email Address” Code Answer. When creating scripts and web applications, error handling is an important part. If your code lacks error checking code, your program may look very unprofessional and you may be open to security risks. Error handling on Database was simple and easy. An error message with filename, line number and a message describing the error is sent to the browser. This tutorial contains some of the most common error checking methods in MySQL. Below are some solution about “Get the User Name and Domain Name from an Email Address” Code Answer.
Get the User Name and Domain Name from an Email Address
DECLARE @Email VARCHAR(50) = 'firstname.lastname@example.org'
SELECT SUBSTRING(@Email, 1, CHARINDEX('@', @Email) - 1) AS [User Name],
SUBSTRING(@Email, CHARINDEX('@', @Email) + 1, LEN(@Email)) AS [Domain Name]