sql - UPDATING column with column from different table with no correlation between the tables -


i have 2 tables.

  • one called tcolor has 2 columns. 1 called "id" , other called "color" color column filled hex color values. id column null values.
  • i have table in same database called testg. testg has 1 column called "id".

i want update (not insert) tcolor's id column using testg's id column.

how without getting ora-01427 error?

also, ids testg, used query below. there way change query update statement wont have pull 1 column 1 table other.

what mean is, taking query, converting update statement, can directly update tcolor id column.

insert testg              (id)  select distinct terr_id    (select distinct jta.terr_id,                          jta.name,                          low_value_char,                          comparison_operator,                          high_value_char,                          jtva.last_update_date,                          jtva.creation_date            jtf_terr_values_all jtva,                 jtf_terr_qual_all jtqa,                 jtf_terr_all jta           jtva.terr_qual_id = jtqa.terr_qual_id                 , jtqa.terr_id = jta.terr_id                 , jta.end_date_active > sysdate                 , jta.name 'us%'                 , low_value_char not null                 , comparison_operator in ( '=' )                 , regexp_like (low_value_char, '^[[:digit:]]+$')          order  6 desc);  

by sounds of it, have table (testg) , want able assign / link distinct color each id in table, assignment arbitrary.

i'd go plain loop. assume there's enough color entries don't run out. make smarter exiting loop once stops finding rows update.

declare     cursor c_1     select distinct testg.id     testg; begin     r_1 in c_1 loop         update tcolor         set id = r_1.id         id null         , rownum = 1;     end loop;     commit; end; / 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -