Jonathan Lockley
Jonathan Lockley

Reputation: 1350

SQL select all does not include @ symbol

I tried this but it doesn't work. I want to find all the inputs which do not have a valid e-mail with an @ symbol

SELECT * FROM tblEmail
WHERE [email] <> '%@'

Upvotes: 0

Views: 1391

Answers (4)

Kami
Kami

Reputation: 19437

Your current query is searching for an @ symbol at the end of the text only. If you need to match anywhere within the text (which is the case for emails) I expect you need to use '%@%'.

Hence your full query might look like

SELECT * FROM tblEmail Where [email] NOT LIKE '%@%'

Upvotes: 1

VeNoMiS
VeNoMiS

Reputation: 330

maybe using NOT LIKE '%@%'

SELECT * FROM tbl where email NOT LIKE '%@%'

Upvotes: 1

jtavares
jtavares

Reputation: 449

To fully validate an email address using mysql you should do:

SELECT * 
  FROM tblEmail 
 WHERE email NOT REGEXP '^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$';

Upvotes: 1

Matteo Tassinari
Matteo Tassinari

Reputation: 18584

Try this:

SELECT * FROM tblEmail WHERE [email] NOT LIKE '%@%'

Upvotes: 1

Related Questions