Skip to content

Instantly share code, notes, and snippets.

@angusdev
Created December 29, 2014 01:55
Show Gist options
  • Select an option

  • Save angusdev/75eb2dd122f52591e6f2 to your computer and use it in GitHub Desktop.

Select an option

Save angusdev/75eb2dd122f52591e6f2 to your computer and use it in GitHub Desktop.
Check validity of email address
SELECT *
FROM EMAIL_TO_CHECK ETC
WHERE ETC.EMAIL IS NOT NULL AND ETC.EMAIL <> 'NA' AND ETC.EMAIL <> 'N/A'
AND ( ETC.EMAIL IS NULL
OR ETC.EMAIL NOT LIKE '%@%'
OR ETC.EMAIL LIKE '%@%\_%' ESCAPE '\'
OR ETC.EMAIL LIKE '%.'
OR LOWER (ETC.EMAIL) LIKE '%@%.co'
OR LOWER (ETC.EMAIL) LIKE '%@%.co.hk'
OR LOWER (ETC.EMAIL) LIKE '%@%.co.mo'
OR LOWER (ETC.EMAIL) LIKE '%@%.co.cn'
OR LOWER (ETC.EMAIL) LIKE '%@%.co.my'
OR LOWER (ETC.EMAIL) LIKE '%@%.co.au'
OR LOWER (ETC.EMAIL) LIKE '%@%.co.tw'
OR LOWER (ETC.EMAIL) LIKE '%@%.com.jp'
OR (NOT REGEXP_LIKE (LOWER (ETC.EMAIL), '\.[a-z][a-z]$'))
AND (NOT REGEXP_LIKE (LOWER (ETC.EMAIL), '\.[a-z][a-z][a-z]$')
AND LOWER (ETC.EMAIL) NOT LIKE '%.asia'
AND LOWER (ETC.EMAIL) NOT LIKE '%.info')
OR ( REGEXP_LIKE (LOWER (ETC.EMAIL), '\.[a-z][a-z][a-z]$')
AND LOWER (ETC.EMAIL) NOT LIKE '%.com'
AND LOWER (ETC.EMAIL) NOT LIKE '%.biz'
AND LOWER (ETC.EMAIL) NOT LIKE '%.edu'
AND LOWER (ETC.EMAIL) NOT LIKE '%.mil'
AND LOWER (ETC.EMAIL) NOT LIKE '%.org'
AND LOWER (ETC.EMAIL) NOT LIKE '%.net'
AND LOWER (ETC.EMAIL) NOT LIKE '%.gov'
AND LOWER (ETC.EMAIL) NOT LIKE '%.pro'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment