I am currently writing update instructions to continually update a query-oriented table. The schema is identical between both tables, and the content is not important:
STAGING ID NAME COUNT PRODUCTION ID NAME COUNT
My update statement is as follows:
update PRODUCTION set name = (select stage.name from staging stage where stage.name=name and rownum <2), count = (select stage.countfrom staging stage where stage.count=count and rownum <2);
It should be noted that 1) at the end of my update there is no where clause (this may be a problem) and 2) all records after the update have the same values. I mean the following:
BEFORE UPDATE: 1,"JOHN", 12; 2,"STEVE",15; 3,"BETTY",2; AFTER UPDATE 1,"JOHN", 12; 2,"JOHN",12; 3,"JOHN",12;
My question is how to fix this so that the table correctly reflects the βnewβ data from the stage as the correct SQL update?
UPDATE
So, my production data may coincide with what is in PRODUCTION
, and for discussion it will be:
STAGING DATA TO MERGE: 1,"JOHN", 12; 2,"STEVE",15; 3,"BETTY",2;
UPDATE second
The query I would like to run would be as follows:
update PRODUCTION set production.name = staging.name, production.count = staging.count where production.name = staging.name;
This leads to invalid id problems on "staging.name"