I would like to write a Select query where I can see if one column is like part of another column in different table postgresql.
tblNames1:
| ID | Description | target table |
|---|---|---|
| 1 | select test.fn_hierarchy_prod_group | test_1 |
| 2 | select run_update_query | test_2 |
| 3 | select func_datad_addr_1 | test_3 |
| 4 | select func_datad_addr | test_4 |
tblNames2:
| ID | Description | target table |
|---|---|---|
| 1082 | fn_hierarchy_prod_group | dba.l |
| 1091 | func_datad_addr | dba.n |
| 1099 | fn_hierarchy_customer | dba.m |
| 1100 | run_update_query | dba.j |
The query should return and update target tblnames1:
| ID | Description | target table |
|---|---|---|
| 1 | select test.fn_hierarchy_prod_group | dba.l |
| 2 | select run_update_query | dba.j |
| 3 | select func_datad_addr_1 | test_3 |
| 4 | select func_datad_addr | dba.n |
I am new to postgres and have search different ways to update it but I am not getting success.I have tried using query like
select *
from tblnames1 a
left join tblnames2 b on 1=1
where b.target_table like concat('%',a.target_table,'%')
But this query is wrong.
Descriptioncolumn in it, not thetarget_table. Depending on where thoseselectstatements in the other description column come from, you might have a bad time matching them if they use varying case and combine that with varying double quoting.