MySQL Insert tables

0

My main local MySQL data base is designed this way Table A

ID | NAME | PHONE
 1 | Jhon | 555
 2 | Carl | 666

where ID is the KEY auto incremental. Furthermore I have also a remote SQLite data.db file which I have to download every month to convert it to MySQL. The result table looks like this Table B

NAME | PHONE
Phil | 777
Ben  | 888

Because Table A doesn't have the same structure as Table B I am not able to join them. Is there a way to insert (import?) Table B into Table A using the auto increment?. like this

ID | NAME | PHONE
 1 | Jhon | 555
 2 | Carl | 666
 3 | Phil | 777
 4 | Ben  | 888

An additional question: If I install MySQL instead of SQLite in the remote Linux can I remotely connect both databases and keep Table A always updated? Thank you in advance.

Joe

Posted 2016-09-29T05:28:54.893

Reputation: 523

Of course you can JOIN it, just use the NAME column...? – Daniel B – 2016-09-29T05:43:26.960

I think it is not related to JOIN. It is related to UNION – Muhammad Ali Khamis – 2016-09-29T05:55:39.410

I edited my question. I need to actual Insert Table B into Table A. So I will have, as a result, a bigger Table A. – Joe – 2016-09-29T06:02:04.747

Answers

0

So what I did was to edit the dump.sql from Table B file and add the name of the of the columns like this

INSERT INTO Column1 (NAME, PHONE) VALUES ('Phil','777');
INSERT INTO Column1 (NAME, PHONE) VALUES ('Benn','888');

for then to run

mysql -u root -p TableA < dump.sql

though, can I actually do it directly without the dump?

Joe

Posted 2016-09-29T05:28:54.893

Reputation: 523

If it's short term, just do what works. If it's long term, redesign the DB that you can change so it fits. – Nelson – 2016-09-29T08:47:13.090

how? I am planing to have one big local Table A being fed by many remote Tables B. As table A will have auto_incremental ID, how can I make this work? – Joe – 2016-09-29T11:53:33.430