Skip to content

Instantly share code, notes, and snippets.

@hardware
Created March 6, 2015 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hardware/5a2fa850411f700ba8b5 to your computer and use it in GitHub Desktop.
Save hardware/5a2fa850411f700ba8b5 to your computer and use it in GitHub Desktop.
Search mail providers in db
CREATE OR REPLACE FUNCTION CHARINDEX(text, text, integer) RETURNS integer AS $$
SELECT CASE WHEN strpos(substr($2, $3+1), $1) = 0 THEN 0
ELSE strpos(substr($2, $3+1), $1) + $3 END;
$$ LANGUAGE SQL IMMUTABLE RETURNS NULL ON NULL INPUT;
SELECT DISTINCT substring(mail,charindex('@',mail,1)+1,length(mail)) FROM table;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment