Oracle SQL update one table based on resulting information from another
Posted on 2014-01-09
There are two tables involved. I am going to list each table and the fields involved in this problem and then write some pseudo code so you can get an idea of what I am trying to accomplish.
UPDATE SET SHIP_TO.DIVISION_ID = 17 WHERE
SHIP_TO.DIVISION_ID IS NULL AND ARCUSTO.EPLANT_ID = 20 AND ARCUSTO.CUSTNO LIKE '*-30'
UPDATE SET SHIP_TO.DIVISION_ID = 16 WHERE
SHIP_TO.DIVISION_ID IS NULL AND ARCUSTO.EPLANT_ID = 20 AND ARCUSTNO.CUSTNO LIKE '*-20'
I left out the joins from ship_to.arcusto_id to arcusto.id because I am not sure how that works in this instance. I am quite comfortable updating data in a single table but when it comes to this type of problem I can't understand the resulting code to make it happen. There usually is a lot of aliases going on and I just can't make sense of it. If someone could explain the answer when the solution is found I would appreciate it. Or send me to some documentation or video so I can actually learn how this works because it keeps coming up! I feel that if I could just get a 15 minute tutorial explaining what the code structure is doing / meaning is all about I would be able to do these types of procedures myself.
Thanks in advance!!