Hello,
I have two tables. I need to join them on a field which is not same but similar. e.g Table1.ColA = '12345', '67890',... and Table2.ColA = '12345/1', '12345/2', '12345/3', '67890/xxx', '67890/yyyy', ...and so on.
So what I need to do is to join those two tables on Table1.ColA like Table2.ColA and update another column in Table2. So after join two tables, in Table2 ColC should be updated from values from Table1 ColC according to ColA values. (and also which join type is better to use here?, inner join or left join?)
Table1
--------
ColA ColB ColC
12345 10 12
67890 10 24
.
.
Table2
---------
ColA ColB ColC
12345/1 10 0 --> 12
12345/2 10 0 --> 12
12345/123 10 0 --> 12
67890/12 10 0 --> 24
67890/5478 10 0 --> 24
.
.
The code that I tried but did not work: (I just tried to see the data before update it but I think my join condition, 'like' statement is not correct.) So can anyone assist me here to join these two tables and write correct syntax? Thanks!!
select * from Table1 T1 left join Table2 T2 on ','||T1.ColA||',' like '%,'||TRIM(T2.ColA)||',%' and T1.ColB = T2.ColB where T2.ColC = 0