Suppose I have the following table (Table1) in MySQL:
FirstName Residence
Bob USA
Jane Canada
Steve China
I also have the following table (Table2) in MySQL:
Residence
Japan
Canada
Mexico
I want to update Table1 so that the final result is:
FirstName Residence
Bob Japan
Jane Canada
Steve Mexico
Right now, I'm thinking of doing the following: 1) make a primary key on both tables 2) drop the "Residence" column from Table1 3) do a join on the tables. Is there an easier, more efficient way to update the column? A join would take at least linear time, when this should be a constant time operation. In addition, using multiple update queries would be tedious and slow.
Inserting a row into a MySQL database seems fairly quick and straightforward. I'm wondering if there is a similarly easy way to insert a column into a MySQL database.
Thanks!