Home > database >  Oracle field is 01,02,03,04 this, how to replace with A, B, C, D
Oracle field is 01,02,03,04 this, how to replace with A, B, C, D

Time:09-20

Oracle AA table fields stored in A content of 01,02,03,04 this, 01 and 02 01 respectively corresponding to another table B B in the field, how to write SQL to AA table of A field how to replace with A, B, C, D (A, B, C, D corresponding table B C field)

CodePudding user response:

Your great god help and have a look

CodePudding user response:

The original data long what kind, what is expected results, use of excel,

CodePudding user response:

Write the original value in excel with the final results

CodePudding user response:

CodePudding user response:

The replace (replace (replace (fields, '01', 'A'), '02', 'B'), '3', 'C')

CodePudding user response:

I this value is not constant 01 and 02, is another table data fields such as ID generated by the splicing series, to replace with another table ID such as the NAME field

CodePudding user response:

 with tab1 as (
Select 'by' 01 id from dual
)
Tab2 as (
Select '01' id, 'A' des from dual union all
Select the '02' id, 'B' des from dual
)
, tab3 as (
The select regexp_substr (t1. Id, '[^,] +' 1, level) r_id, level lv, t1. Id from tab1 t1
Connect by t1. Id=the prior t1. Id
And the prior sys_guid () is not null
And level & lt;=regexp_count (t1. Id ', ') + 1
)
Select a t1. Id, listagg (t2) des, ', ') within group (order by t1. Lv) from tab3 t1, tab2 t2
Where a t1. R_id=t2. Id
Group by t1. Id
;

CodePudding user response:

SELECT the biggest, AA. Field FROM AA LEFT JOIN B ON AA. A=B.B

CodePudding user response:

The update aa set id=decode (' 01 ', 'A', '02', 'B',... )

CodePudding user response:

This should be what you want, through b table name field to update aa table id field

The update aa set id=(select bb. Name the from bb where aa. Id=bb. Id)
Where the exists (select 1 from bb where aa. Id=bb. Id)