Tabular IQ
Back to Function Index

CONTAINS()

Overview

CONTAINS() performs a case-sensitive search for a substring within a string. If the search string is found within the target string, the function returns TRUE; otherwise, it returns FALSE. This function is commonly used for text searching, filtering, and conditional logic based on string content.

Function Format

CONTAINS(string, search_string)

Return Value

CONTAINS() returns a Boolean value (TRUE or FALSE)

Examples


CONTAINS("Green apples taste better than red apples.", "apples")     = TRUE
CONTAINS("Green apples taste better than red apples.", "oranges")    = FALSE
CONTAINS("Hello World", "world")                                     = FALSE  (case sensitive)
CONTAINS("Hello World", "World")                                     = TRUE
CONTAINS("", "test")                                                 = FALSE  (empty string)
CONTAINS("test", "")                                                 = TRUE   (empty string is contained in any string)
CONTAINS("Multiple words here", "words")                             = TRUE

Notes

  • The search is case-sensitive. "Hello" and "hello" are considered different strings.
  • If the search string is empty (""), the function returns TRUE for any non-NULL input string.
  • If the input string is empty (""), the function returns FALSE unless the search string is also empty.
  • NULL values in either parameter will result in a NULL return value.
  • This function is commonly used in:
    • Text filtering and searching
    • Conditional logic in formulas
    • Data validation
    • Content filtering
  • For case-insensitive searches, consider using LOWER() or UPPER() on both strings.

See Also