Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- array ('hello world', 'foo', 'bar') -- terms here have only letters and one space at most
- CREATE OR REPLACE FUNCTION my_stupid_query(q text)
- RETURNS text[] AS $$
- SELECT ARRAY(
- SELECT regexp_replace(t, '[^[:alpha:]]', '_', 'g')
- FROM unnest(string_to_array(q, ' ')) AS q(t)
- );
- $$ LANGUAGE sql
- IMMUTABLE;
- SELECT word
- FROM (VALUES (ARRAY['hello world', 'foo', 'bar'])) AS t1(x)
- CROSS JOIN (VALUES ('foo hello-world helloXworld') ) AS query(q)
- CROSS JOIN unnest(x) AS t2(word)
- WHERE NOT word LIKE ANY(my_stupid_query(q));
- word
- ------
- bar
- (1 row)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement