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.

3
  • Of course you can JOIN it, just use the NAME column...?
    – Daniel B
    Sep 29, 2016 at 5:43
  • I think it is not related to JOIN. It is related to UNION Sep 29, 2016 at 5:55
  • 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
    Sep 29, 2016 at 6:02

1 Answer 1

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?

2
  • 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
    Sep 29, 2016 at 8:47
  • 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
    Sep 29, 2016 at 11:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .