0

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

2
  • Does Table1.Original_id point to Table2.id? Or is it different?
    – matigo
    Jun 13, 2021 at 1:56
  • @matigo yes, sorry forgot to mention that, will fix
    – Leb_Broth
    Jun 13, 2021 at 1:59

1 Answer 1

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.