mb1987
mb1987

Reputation: 467

selecting space in between Emails

I am using MySQL I have a table called Associations where there is a column called Email

Emails are in format [email protected]

if I want to select all emails which have word webmaster I use query.

 select * from associations where email like '%webmaster%';

there are some emails which has space and are not in format abc.xyz.com

they are in format like  @abc. xyxyz . com

how can i select all emails that have space in between them.

Upvotes: 1

Views: 614

Answers (2)

David Faber
David Faber

Reputation: 12485

If you wanted to find emails that have any sort of whitespace in them (e.g., spaces, tabs, etc.), then you might want to use the following:

SELECT * FROM associations
 WHERE email RLIKE '\s'

One caveat is that matching regular expressions is a heavy CPU operation.

Upvotes: 0

Gordon Linoff
Gordon Linoff

Reputation: 1270421

You can use like:

where email like '% %'

To get a lot of bad format emails, you could do:

where email like '% %' or
      email not like '%@%.%'

Upvotes: 3

Related Questions