I'd like to query rows from database that might start with any word from an alternation list. For instance, querying the name blue tree house
would return records such as the blue tree house
or le blue tree house
or A blue tree house
.
I attempted querying as follows:
SELECT NAME
FROM NAMES
WHERE (lower(names.name) ~ '^(no.?)*\s*\d*\s*\W*(an|the|le|leur|ils|a)?(blue)\W*\s*\y') AND
(lower(names.name) ~ ' \yhouse ?\y')
Here the Fiddle with additional examples and setup.