0

I have two tables on server B called Employee_data and Employee_Salary. I need to create a new table on server A which has columns from both the tables.

Employee_Data has Employee_id, join_date, Employee_name, employee_photo_url
Employee_salary has employee_id, employee_ssn, employee_autoincrement_id, emp_salary

I need to join them to get Employee_id, name, emp_salary and emp_autoincrement_id where Employee_id are equal.

The join is pretty straightforward but how can I insert the data in a table on a different server A?

I will be using php to auto-update the table on server A daily. Can I pass the result of a query on server B to a table on server A as the input?

Jens
  • 67,715
  • 15
  • 98
  • 113
user3766332
  • 319
  • 1
  • 5
  • 17

1 Answers1

1

You need to learn the concept called as FEDERATED . It is a storage engine that accesses data in tables of remote databases in mysql.

Naveen
  • 1,496
  • 1
  • 15
  • 24
  • Is there no way to do this using PHP? Can't I store the selected columns in a resource and then use them to populate the other table, somehow? – user3766332 Jul 16 '14 at 06:19
  • Without connecting two different servers, its straight forward, you just have to have two connection strings. Pull data using one connection string and insert it using another. – Naveen Jul 16 '14 at 06:24
  • Thank you for your reply. The data is pulled as a resource when I execute my first query. How can I use this resource to populate the second table? The syntax doesn't seem to be available on the internet. – user3766332 Jul 16 '14 at 06:26
  • Its will be normal insert using php, if you don't have huge number of rows just insert using loop. For bulk insert you can check this link also http://stackoverflow.com/questions/779986/insert-multiple-rows-via-a-php-array-into-mysql. – Naveen Jul 16 '14 at 06:29
  • Check this also for bulk data insert http://programmers.stackexchange.com/questions/106167/what-is-the-best-way-to-insert-a-large-dataset-into-a-mysql-database-or-any-dat – Naveen Jul 16 '14 at 06:31