Skip to content

Instantly share code, notes, and snippets.

@igeligel
Created October 27, 2019 14:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igeligel/4a58593a82fd785629f20571b72c36e0 to your computer and use it in GitHub Desktop.
Save igeligel/4a58593a82fd785629f20571b72c36e0 to your computer and use it in GitHub Desktop.
# Get all entries like Melissa, Melli.
# Not depending on how many characters are wildcarded.
SELECT * FROM example_table WHERE example_column LIKE 'Mel%';
# Get all entries like Meli, Melo.
# Depending on how many characters are wildcarded.
SELECT * FROM example_table WHERE example_column LIKE 'Mel_';
# Or for multiple characters, here 2
SELECT * FROM example_table WHERE example_column LIKE 'Mel__';
# Get all entries which include mel, not case-sensitive.
# To match: Melissa, Emelio, Mel
SELECT * FROM example_table WHERE LOWER(example_column) LIKE '%mel%';
# With an ILIKE expression
SELECT * FROM example_table WHERE example_column ILIKE '%mel%';
# With a regular expression (Regex)
SELECT * FROM example_table WHERE example_column ~* 'mel';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment