Reputation: 1656
I have two tables.
Table A is a list of invoices each with a unique invoice ID.
Table B is a list of invoice attributes with a unique invoice ID that corresponds to those in Table A.
I want to add a new column to table A called "Contact Name" by looking up that value by invoice ID in table B.
I know I could create a temp table by joining TableA and TableB, and then replace the existing table with that new one... but I'm curious if there is a better way to do this.
Upvotes: 1
Views: 4738
Reputation: 668
alter table A add CONTACT_NAME VARCHAR2(50);
update A
set contact_name = (select value from B where B.invoice_id = A.invoice_id);
Upvotes: 5