4seen — 2010-09-27T23:50:02-04:00 — #1
Okay basically, I have 2 tables which have over 2,000 records:
I have Table A which has the following fields:
address, zip, state, country, ID(this is a primary Key)
I have Table B which has the following fields:
address, zip, state, country, ID(this is a primary Key), + 10 other fields.
I need to import all the fields from Table A into Table B. All the 10 fields in Table B are populated so I can not lose this data. The ID is the only thing that matches both tables.
The field structure from both tables are the same, so if needed Table A can overwrite all the data in Table B only pertaining to the fields being copied over.
I am trying to do this via phpmyadmin using an SQL statement. I tried to export Table A and import it into Table B but it is not working and I get timeout errors.
I've googled for over an hour but even though I find similar questions.. I can not find my exact question and to be honest I am pretty lost.
Any help would be much appreciated.
4seen — 2010-09-28T13:36:00-04:00 — #2
Thank you both for your replies, I used the code below and it worked perfect! Thank you!
system — 2010-09-28T05:07:31-04:00 — #3
set tblB.colA = (select tblA.colA from tblA where tblA.ID = tblB.ID)
you will need a set...... for each column you want to update.
r937 — 2010-09-28T06:26:26-04:00 — #4
ON tableB.id = tableA.id
SET tableB.address = tableA.address
, tableB.zip = tableA.zip
, tableB.state = tableA.state
, tableB.country = tableA.country