Recently, we have changed from MySQL to PostgreSQL. Most of the queries have been translated except for the ones with the Mysql 'REGEXP' keyword:
MySQL (prepared statement):
SELECT * FROM table WHERE ? REGEXP identifier;
We have a 'table', and one of the columns is called 'identifier'. This 'identifier' column contains the actual regular expression pattern.
So, instead of 'hard-coding' the regexp pattern in the query, it looks-up the identifier column for the pattern.
In Postgresql, we need to use the '~' keyword instead of the 'REGEXP' one (which is MySQL only), but with Postgresql I cannot seem to extract the pattern from a column.
I've tried following queries without success:
SELECT * FROM table WHERE 'test' ~ "identifier";
ERROR: invalid regular expression: parentheses () not balanced
SELECT * FROM table WHERE "identifier" ~ 'test';
-> no results
for testing purposes I created a number of records where the "identifier" column contains '.*' as value (regular expression for match everything), but still I do not get the appropriate result.
Help is very much welcome, thank you!