I am currently using a query, however sometimes it doesn't update all fields. I need a workaround on this. Can anybody help me?
update table1
set number =
(
select substring(number from offset)
from table2
where strpos(number,prefix) = '1'
order by length(prefix)
desc limit '1'
) ;
table1:
number
----------
1001123456
table2:
prefix | offset
-------+-------
1001 | 5
My goal, hopefully, is to retrieve only the substring (in this example "123456" for every row in table1 that matches the specific prefix in table2.
Any help would be greatly appreciated! Thank you!