Click here to Skip to main content
15,885,435 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Everyone,

I would like to humbly ask your advice with this particular sql query.
I am trying to create a MySQL query where i can copy all records from one Database Table (REMOTE SERVER) to Database Table (LOCAL SERVER). I think it would be MySQL Insert Into Select Statement which i found at http://www.w3schools.com/sql/sql_insert_into_select.asp

Example

INSERT INTO tbl_remote_table
col_mname,col_lname,col_username,col_password,col_question,col_answer,col_email,col_status,col_photo)

SELECT col_eid, col_fname, col_mname,col_lname,col_username,col_password,col_question,col_answer,col_email,col_status,col_photo
FROM tbl_local_table

The problem here is the example given above by the source is for 2 tables in one database only.



Example:

REMOTE SERVER:

SERVER IP: '192.168.1.149'
PORT: '3306'
USERNAME: 'root'
PASSWORD: '1234'
Database: 'db_brgy_pamplonados_backup'
Table: 'tbl_remote_table'

LOCAL SERVER

SERVER IP: 'localhost'
PORT: '3306'
USERNAME: 'root'
PASSWORD: '1234'
Database: 'db_brgy_pamplonados'
Table: 'tbl_local_table'


Database Table (REMOTE SERVER) to Database Table (LOCAL SERVER) has the same design below:

Inline image 1




Below are the following fields i want to copy from Table 1 to Table 2

col_eid
col_fname
col_mname
col_lname
col_username
col_password
col_question
col_answer
col_email
col_status
col_photo

Waiting for your positive reply.



Additionally. I will run the said SQL query from an external program (VB.NET)
So that from a scheduled time the program can upload local table copy to the Remote MySQL Server

What I have tried:

Example

INSERT INTO tbl_admin1
(col_eid, col_fname, col_mname,col_lname,col_username,col_password,col_question,col_answer,col_email,col_status,col_photo)

SELECT col_eid, col_fname, col_mname,col_lname,col_username,col_password,col_question,col_answer,col_email,col_status,col_photo
FROM tbl_admin2
Posted
Updated 19-Jun-16 22:35pm
v4
Comments
Herman<T>.Instance 20-Jun-16 1:58am    
FROM [servername].[schemaname].[tablename]
JMAM 20-Jun-16 2:45am    
Hi digimanus,

Thanks for the response I will run the said SQL query from an external program (VB.NET)
So that from a scheduled time the program can upload local table copy to the Remote MySQL Server

I think then query should look like

INSERT INTO tbl_remote_table
col_mname,col_lname,col_username,col_password,col_question,col_answer,col_email,col_status,col_photo)

SELECT col_eid, col_fname, col_mname,col_lname,col_username,col_password,col_question,col_answer,col_email,col_status,col_photo
FROM tbl_local_table
Mohibur Rashid 20-Jun-16 4:23am    
Read the solution offered in Stackflow. People who comes here offer free service. if you plan to offer money this is not the right place. Your statement is abusive from my point of view.
JMAM 20-Jun-16 4:37am    
Sorry, i have mistakenly included that offer which i intend to resend to someone else who is a freelance mysql programmer i know, but i haven't got a reply from here. Thanks anyway.

1 solution

 
Share this answer
 
Comments
JMAM 20-Jun-16 2:45am    
Hi Mehdi Gholam,

Thanks for the response I will run the said SQL query from an external program (VB.NET)
So that from a scheduled time the program can upload local table copy to the Remote MySQL Server

I think then query should look like

INSERT INTO tbl_remote_table
col_mname,col_lname,col_username,col_password,col_question,col_answer,col_email,col_status,col_photo)

SELECT col_eid, col_fname, col_mname,col_lname,col_username,col_password,col_question,col_answer,col_email,col_status,col_photo
FROM tbl_local_table
Mohibur Rashid 20-Jun-16 4:15am    
Don't forget to take $5 From OP. If you do not know what I am talking about then read his fifth paragraph :D hahahahahahahahaha
JMAM 20-Jun-16 4:37am    
Sorry, i have mistakenly included that offer which i intend to resend to someone else who is a freelance mysql programmer i know, but i haven't got a reply from here. Thanks anyway.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900