Finding similar items from a list of Text(identical to a LIKE condition)

I am trying to write a query to solve the below question.

Names = [“Ankit”, “Ismaen”, “Drew”, “Ankit Chaudhari”, “John”]
I want to return all names that have “Ank” in them.
So my result would be like: [“Ankit”, “Ankit Chaudhari”]

I know there is STRING_FIND that looks for a particular substring within a string, can’t seem to find anything similar when checking for list of text.

1 Like

Great question!

Essentially you loop through and check to see if any of the items in the array exist in the string using STRING_FIND() by checking if its not equal to -1. You also want to make sure you either make the items uniform by passing it through a LOWERCASE() function.

Hope this helps!

FROM
  name
IN
  names
WHERE
  STRING_FIND(LOWERCASE(name), "ank") <> -1
SELECT
  name

2 Likes