[UPHPU] final answer...
lists at strictlyrockymountain.com
Sun Apr 2 01:53:34 MST 2006
> Wouldn't it be a little simpler to do the following:
> SELECT DISTINCT RIGHT(email, LENGTH(email) - LOCATE('@', email)) AS
> domain FROM table ORDER BY domain
> - Josh
Hey Josh or anyone, did you try your query above? I just tried it on a
list of email addresses of a customer - which is not very clean. I mean
that the email address field didn't used to be verified as being the right
format etc, and your query gives off a different result than the "LEFT()"
query does. I would have expected the two to produce the same results as
they look like they do the same thing.
SELECT DISTINCT REVERSE(LEFT(REVERSE(email),LOCATE('@',REVERSE(email)) -
1)) AS domain
SELECT DISTINCT RIGHT(email, LENGTH(email) - LOCATE('@', email)) AS domain
FROM table ORDER BY domain
For instance, an email entered is "babybear3776yhahoo.com". Obviously
missing the "@" sign and yahoo spelled wrong. With the LEFT() query this
email is not in the result output, which would seem correct since LOCATE
dosn't ever find the "@". But with the RIGHT() query it shows up. Try it
out. Any ideas why the RIGHT() results show it, it's using LOCATE to find
the "@" also.
More information about the UPHPU