MySQL – Update Table Column Based on Another Table Values

MySQL

I have two tables:
Table 1:

ID    TICKET_AGENT    ORIGINAL_ID 
1          0               5
2          0               3
3          0               1
4          0               2

And,
Table 2:

ID    TICKET_AGENT 
1          A               
2          C               
3          B               
4          B

Is there any scenario where I can use UPDATE to update Table 1.TICKET_AGENT field by searching through ORIGINAL_ID as the ID of Table 2 and if ORIGINAL_ID is found in table 2, update table 1 after with the corresponding TICKET_AGENT value?

UPDATE: ORIGINAL_ID points to ID in table 2

Best Answer

You can just do a joined update

update table1
inner join table2 on table2.ID = table1.ORIGINAL_ID
set table1.TICKET_AGENT = table2.TICKET_AGENT