I am using a postgres version 8.3 (greenplum). I am trying to compare two tables on a single column called col_name. What I need is a partial string compare on both the column row values. The values are xx.yyy.zzz. I want to pull out the first part namely 'xx' and truncate after that namely '.yyy.zzz'. I only want to compare for two rows for the string till the first period is encountered. There is possibility that the part of the string xx is of varying lengths in characters.
I am using the following logic, but I cant see why it is not working:
select
distinct x.col_name,
x.col_num
from table_A x
left outer join table_b y
on
regexp_matches((x.col_name,'^(?:([^.]+)\.?){1}',1),(y.col_name,'^(?:([^.]+)\.?){1}', 1))
and x.col_num=y.col_num;
I am getting this error:
ERROR: function regexp_matches(record, record) does not exist LINE 36: regexp_matches((x.col_name,'^(?:([^.]+).?){1}', 1),(y.... ^ HINT: No function matches the given name and argument types. You may need to add explicit type casts. ********** Error **********
ERROR: function regexp_matches(record, record) does not exist SQL state: 42883 Hint: No function matches the given name and argument types. You may need to add explicit type casts. Character: 917
Can anyone help me out?
Thanks!