Please help me. I don't know how to combine two database table into one in two databases. I tried to combined them using mysql JOIN but, it doesn't work. I appreciated all your responses. Here is screenshots of the mysql databases:
Asked
Active
Viewed 248 times
-1
-
similar issue in this post. https://stackoverflow.com/questions/5145637/querying-data-by-joining-two-tables-in-two-database-on-different-servers – Tran Ho Sep 14 '18 at 01:56
-
What is your expected output? Please include all data directly in your question, as _text_, formatted as code with four or more spaces on each line. – Tim Biegeleisen Sep 14 '18 at 01:57
-
I wanted to get the data in 'thesis_carinan'(database) 'user' (db table) and combine them in 'thesis' (database) 'user'(db table) – John Mark Sep 14 '18 at 02:04
-
Possible duplicate of [Join between tables in two different databases?](https://stackoverflow.com/questions/5698378/join-between-tables-in-two-different-databases) – Ultimater Sep 14 '18 at 02:29
2 Answers
0
My guess is that you want a union here:
SELECT name, gender, college, course, email, mob, password
FROM thesis.user
UNION ALL
SELECT name, gender, college, course, email, mob, password
FROM thesis_carinan.user;
I am suggesting a union because both your tables have identical structure, and combining via a union would seem to make more sense than using a join.

Tim Biegeleisen
- 502,043
- 27
- 286
- 360
-
Hey Tim Biegeleisen! thank you for your response. I run your code but, I got an error message saying Table 'thesis.thesis' doesn't exist. – John Mark Sep 14 '18 at 02:22
-
I am sorry but it didn't work for me when to test it. just need specify the table like `SELECT name, gender, college, course, email, mob, password FROM thesis.user UNION ALL SELECT name, gender, college, course, email, mob, password FROM thesis_carinan.user;` – dwir182 Sep 14 '18 at 02:22
-
@JohnMarkBondad I wasn't sure if these tables were really in separate databases. Just preface the table name by the database, and it should work. – Tim Biegeleisen Sep 14 '18 at 02:23
0
From Tim Answer you can add specify Table
More like this:
SELECT name, gender, college, course, email, mob, password
FROM thesis.user
UNION ALL
SELECT name, gender, college, course, email, mob, password
FROM thesis_carinan.user;

dwir182
- 1,539
- 10
- 20