Reputation: 177
I have a table with regular expressions which I need to use to filter rows from another table.
Something like:
SELECT *
FROM a
WHERE foo SIMILAR TO '(SELECT regex FROM b)'
Obviously, that doesn't work because that isn't the syntax and there are multiple rows in b
that I need to iterate through.
I'm using PostgreSQL 8.3.
Upvotes: 4
Views: 332
Reputation: 12485
Perhaps doing a join would work? E.g.
SELECT a.*, b.regex
FROM a JOIN b ON a.foo ~ b.regex
I'm afraid I'm not familiar enough with Postgres to say for certain, but this would be the ordinary way in SQL of iterating over rows. It should return a.foo multiple times if multiple regexes are matched.
Upvotes: 5