Output is example.com
In above query we first used two functions, char_legth() to know the total length of the string, then used LOCATE to get the position of the @ in the email address.
By subtracting these two values we get the length of the string present towards right of the @ in the email address. Then we used RIGHT function to get the part of the string towards right of @.
In this query we used @ as the landmark to break the string.
This query is part of several sub quires, for better understanding you can try small parts of the above complex query
SELECT LOCATE('@','userid@example.com')
Output is 7 , this is the position of @ from left side
SELECT char_length('userid@example.com')
Output is 18, this is the total length of the string
Output is 11, that is the length we require to get the domain part from the email address. Now by using RIGHT function we will get the last 11 chars from the string.