Created
July 5, 2018 01:18
-
-
Save searls/cb59744b49b3beb0a4d2d1573d7f4299 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Query to find for a given array of strings whether a PG array | |
-- column of strings matches any of the given strings after being | |
-- trimmed and uppercase (where && is the intersection operator) | |
SELECT assignments.* | |
FROM assignments | |
WHERE assignments.user_id = 42 | |
AND (upper(regexp_replace(synonyms::text, '\s+', '', 'g'))::text[] | |
&& ARRAY['THING1','THING2']::text[]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment