The two databases in mysql have different table structures. how can we import data from one table to another? mysql has different structures in the two databases. how can we import data from one table to another?
Reply to discussion (solution)
If the table structure is different, you can only use php to read data and then insert the data. why? Can computers communicate with you intelligently?
After checking the fields in table A in php, fill the specified fields with custom items or retrieve the extra fields and then put them into Table B.
How can this problem be solved?
The structure of the two tables is given, and the fields of the table to be imported to the other table are described.
This is the structure of the table to be imported.
Create table if not exists 'job _ HR '(
'M _ id' int (10) unsigned not null AUTO_INCREMENT,
'M _ login' varchar (50) not null,
'M _ pwd' varchar (32) not null,
'M _ sendemail 'tinyint (1) not null default '0 ',
'M _ question 'varchar (50) not null,
'M _ answer 'varchar (50) not null,
'M _ typeid' tinyint (1) not null default '0 ',
'M _ groupid 'tinyint (2) not null default '0 ',
'M _ email 'varchar (100) not null,
'M _ email2 'varchar (100) default null comment 'backup mailbox (S + )',
'M _ emailshowflag' tinyint (1) not null default '0 ',
'M _ name' varchar (200) not null,
'M _ sex' tinyint (1) not null default '0 ',
'M _ birth 'date not null default '2017-00-00 ',
'M _ cardtype' tinyint (1) not null default '0 ',
'M _ idcard 'varchar (20) not null,
'M _ marriage' varchar (10) not null,
'M _ polity 'varchar (10) not null,
'M _ hukou' varchar (100) not null,
'M _ seat' varchar (100) not null,
'M _ edu' tinyint (2) not null,
'M _ address' varchar (200) not null,
'M _ post' varchar (6) not null,
'M _ contact' varchar (50) not null,
'M _ chat' varchar (20) not null,
'M _ tel 'varchar (100) not null,
'M _ telshowflag 'tinyint (1) not null default '0 ',
'M _ fax' varchar (50) not null,
'M _ url' varchar (100) not null,
'M _ regdate' int (11) not null,
'M _ logindate' int (11) not null,
'M _ loginip' varchar (15) not null default '000. 000.000.000 ',
'M _ loginnum' int (10) not null,
'M _ level' varchar (50) not null,
'M _ balance 'int (10) not null default '0 ',
'M _ integral' int (10) not null default '0 ',
'M _ flag' tinyint (1) not null default '0 ',
'M _ startdate' date not null default '2017-00-00 ',
'M _ enddate' date not null default '2017-00-00 ',
'M _ resumenums' mediumint (6) not null default '0 ',
'M _ mysendnums' mediumint (6) not null default '0 ',
'M _ myinterviewnums' mediumint (6) not null default '0 ',
'M _ myfavoritenums 'mediumint (6) not null default '0 ',
'M _ letternums' tinyint (2) not null default '0 ',
'M _ hirenums' mediumint (6) not null default '0 ',
'M _ interviewnums' mediumint (6) not null default '0 ',
'M _ expertnums' mediumint (6) not null default '0 ',
'M _ comm 'tinyint (1) not null default '0 ',
'M _ commstart' date not null default '2017-00-00 ',
'M _ commend 'date not null default '2017-00-00 ',
'M _ logo 'varchar (50) not null,
'M _ logostatus' tinyint (1) not null default '0 ',
'M _ logoflag 'tinyint (1) not null default '0 ',
'M _ logocomm 'tinyint (1) not null default '0 ',
'M _ logostartdate' date not null default '2017-00-00 ',
'M _ logoenddate' date not null default '2017-00-00 ',
'M _ licence 'varchar (100) not null,
'M _ trade 'varchar (50) not null,
'M _ tradeid' smallint (5) not null,
'M _ ecoclass' varchar (20) not null,
'M _ fund 'mediumint (6) not null default '0 ',
'M _ workers' varchar (10) not null,
'M _ founddate 'date not null default '2017-00-00 ',
'M _ introduce 'mediumtext not null,
'M _ teachers' mediumtext not null,
'M _ achievement 'mediumtext not null,
'M _ hits 'int (10) not null default '0 ',
'M _ template' varchar (20) not null,
'M _ activedate' datetime not null default '2017-00-00 00:00:00 ',
'M _ mobile' varchar (20) not null,
'M _ mobileshowflag' tinyint (1) not null default '0 ',
'M _ smsnum' smallint (4) not null default '0 ',
'M _ hirenum 'smallint (4) not null default '0 ',
'M _ myinterviewnum' smallint (4) not null default '0 ',
'M _ expertnum 'smallint (4) not null default '0 ',
'M _ recyclenums' mediumint (6) not null default '0 ',
'M _ recyclenum 'smallint (4) not null default '0 ',
'M _ contactnums' mediumint (6) not null default '0 ',
'M _ contactnum 'smallint (4) not null default '0 ',
'M _ smsnums' mediumint (6) not null default '0 ',
'M _ mysendnum' smallint (4) not null default '0 ',
'M _ myfavoritenum' smallint (4) not null default '0 ',
'M _ ishire 'smallint (4) not null default '0 ',
'M _ operator' varchar (20) not null,
'M _ map' varchar (50) not null,
'M _ confirm' tinyint (1) not null default '0 ',
Primary key ('m _ id '),
KEY'm _ regdate' ('m _ regdate '),
KEY'm _ enddate' ('m _ enddate '),
KEY'm _ logindate' ('m _ logindate '),
KEY'm _ login' ('m _ login '),
KEY'm _ activedate' ('m _ activedate '),
KEY'm _ startdate' ('m _ startdate '),
KEY'm _ ishire '('m _ ishire '),
KEY'm _ logoflag '('m _ logoflag '),
KEY'm _ logostatus' ('m _ logostatus ')
) ENGINE = MyISAM DEFAULT
CHARSET = gbk AUTO_INCREMENT = 122851;
This is a table with data.
Create table jobinfo (
Id int (11)
Jname varchar (50)
Jdesc text
Jexp varchar (20)
Knw varchar (20)
Mgexp varchar (30)
Jattr varchar (10)
Num varchar (10)
Paymt varchar (10)
Conn text
Waddr varchar (100)
Pdate varchar (20)
Jtype varchar (20)
Cid varchar (10)
Url varchar (50)
Compname varchar (50)
Companyaddr varchar (0, 1000)
Mailbox varchar (1000)
Cmsg varchar (1000)
Linkman varchar (20)
)
I'm going to. in this data table, have you put all the fields in one table with so many fields?
Only insert the data in the following table into the first table
You didn't give which field to put in which field
For example, put companyaddr in the jobinfo table into m_address in the job_hr table.
For example, put companyaddr in the jobinfo table into m_address in the job_hr table.
You have already completed most of the work.
For example
Insert into job_hr (m_address) values select companyaddr from jobinfo
They are in two non-databases. Is there any code? it is very troublesome to add them one by one. thank you!
This post was last edited by xuzuning at 06:50:08
Insert into job_hr (database 1. m_address) values select companyaddr from Database 2. jobinfo
Of course, you cannot add them one by one, that is, add them.
Insert into library 1. job_hr (field list) list of fields corresponding to values select from Library 2. jobinfo
Table update based on the master key
Insert into job_hr (database 1. m_address) values select companyaddr from Database 2. jobinfo
Of course, you cannot add them one by one, that is, add them.
Insert into library 1. job_hr (field list) list of fields corresponding to values select from Library 2. jobinfo
11 # experts ~ So if the data types are different, for example, if both of them are char, can they?
I have done it. thank you for your help.
How did you deal with it?
How can this problem be solved? It is urgently needed. if there is a lot of data in the table, for example, how to migrate millions of data records?
Write programs honestly