NOT LIKE

All functions > COMPARISON > NOT LIKE

Returns TRUE if a string does NOT match a specified pattern with wildcards.

Syntax

string NOT LIKE pattern

Function form

Returns: TRUE if the string matches, FALSE if not, NULL if an input is NULL

NOT_LIKE(expr1: VARCHAR, expr2: VARCHAR, [escape: VARCHAR]) → BOOLEAN
sql
ParameterTypeRequiredDescription
expr1VARCHARYesString to match
expr2VARCHARYesPattern (% and _ wildcards)
escapeVARCHARNoEscape character for wildcards

Notes

  • Opposite of LIKE
  • Wildcard pattern matching (%, _)
  • Case-sensitive matching
  • NULL inputs return NULL

Examples

Basic pattern matching

FeatureQL
RETURN
    -- No match
    f1 := 'hello' NOT LIKE 'world',
    -- Does start with 'h'
    f2 := 'hello' NOT LIKE 'h%',
    -- Does end with 'o'
    f3 := 'hello' NOT LIKE '%o',
    -- Does contain 'll'
    f4 := 'hello' NOT LIKE '%ll%',
    -- Does match pattern
    f5 := 'hello' NOT LIKE 'h_llo',
    -- Case sensitive
    f6 := 'hello' NOT LIKE 'HELLO'
;
Result
f1 BOOLEANf2 BOOLEANf3 BOOLEANf4 BOOLEANf5 BOOLEANf6 BOOLEAN
truefalsefalsefalsefalsetrue

NULL handling

FeatureQL
RETURN
    -- NULL string
    f1 := NULL::VARCHAR NOT LIKE 'pattern',
    -- NULL pattern
    f2 := 'text' NOT LIKE NULL::VARCHAR
;
Result
f1 BOOLEANf2 BOOLEAN
NULLNULL

File extension filtering

FeatureQL
RETURN
    -- Not a text file
    f1 := 'document.pdf' NOT LIKE '%.txt',
    -- Not a text file
    f2 := 'data.csv' NOT LIKE '%.txt'
;
Result
f1 BOOLEANf2 BOOLEAN
truetrue

NOT_LIKE — functional call

FeatureQL
RETURN
    -- `NOT_LIKE(expr, pattern)` matches keyword `NOT LIKE`
    f1 := NOT_LIKE('hello', 'world')
;
Result
f1 BOOLEAN
true

NOT_LIKE — chained

FeatureQL
RETURN
    -- Receiver is the string; argument is the pattern
    f1 := ('hello').NOT_LIKE('world')
;
Result
f1 BOOLEAN
true