|
Posted by gosha bine on 09/11/07 08:20
On 11.09.2007 04:10 axlq wrote:
> I'm trying to figure out a MySQL query expression to match an email
> address. Here's the situation:
>
> User registers on my site with a "plus style" email address
> (username+key@example.com). This is a perfectly legal address and I
> don't want to disallow it, because I use this style myself and find
> it useful. For example user+whatever@gmail.com will get delivered
> to user@gmail.com.
>
> Now, the user forgets his password. He is prompted to enter his
> email address, to which my site will send a temporary password.
>
> Problem: if he enters username@example.com instead of the address
> username+key@example.com that's stored in my database, I should be
> able to find the address. How do I construct a MySQL query to match
> what the user enters with the "plus" address in the database?
>
> The simplest way is to strip the +suffix from the username when the user
> first registers on my site, but I'd rather not do that.
>
> -A
hi
you can use mysql regular expressions, e.g.
select * from users where email rlike 'user([+][^@]+)?@example[.]com'
or, if you need this query often create an extra "canonical email"
column in the database.
--
gosha bine
makrell ~ http://www.tagarga.com/blok/makrell
php done right ;) http://code.google.com/p/pihipi
Navigation:
[Reply to this message]
|