Import/Exporting certain columns of a table across two databases and excluding duplicate emails in mysql -


i have run problem mysql queries:

basically, have 2 databases both contain table called tblclients db1 has far more records db2 , there duplicate records (the users have email address in both databases excluded operation). intend append db1 db2 in way columns appended long email address not found.

i have done mysql gives me error. first complains no database selected , if type use db1; before actual statement, generates error:

error 1064 (42000) @ line 1: have error in sql syntax; check manual corresponds mysql server version right syntax use near db1.tblclients (db1.tblclients.firstname, db1 @ line 1

any though on this?

someone told me use mysqldump instead believe done in 1 line mysql query used in bash script file.

thanks

insert db1.tblclients              (db1.tblclients.firstname,               db1.tblclients.lastname,               db1.tblclients.companyname,               db1.tblclients.email,               db1.tblclients.address1,               db1.tblclients.address2,               db1.tblclients.city,               db1.tblclients.state,               db1.tblclients.postcode,               db1.tblclients.country,               db1.tblclients.phonenumber,               db1.tblclients.password,               db1.tblclients.authmodule,               db1.tblclients.authdata,               db1.tblclients.status,               db1.tblclients.pwresetkey,               db1.tblclients.pwresetexpiry,               db1.tblclients.emailoutput)  values      (select db2.tblclients.firstname,                      db2.tblclients.lastname,                      db2.tblclients.companyname,                      db2.tblclients.email,                      db2.tblclients.address1,                      db2.tblclients.address2,                      db2.tblclients.city,                      db2.tblclients.state,                      db2.tblclients.postcode,                      db2.tblclients.country,                      db2.tblclients.phonenumber,                      db2.tblclients.password,                      db2.tblclients.authmodule,                      db2.tblclients.authdata,                      db2.tblclients.status,                      db2.tblclients.pwresetkey,                      db2.tblclients.pwresetexpiry,                      db2.tblclients.emailoutput                not exists (select db2.tblclients.email                                   db2.tblclients.email =                                         db1.tblclients.email));  

try

insert db1.tblclients  (   firstname, lastname, companyname,   email, address1, address2, city, state,   postcode, country, phonenumber, password,   authmodule, authdata, status, pwresetkey,    pwresetexpiry, emailoutput ) select    firstname, lastname, companyname,   email, address1, address2, city, state,   postcode, country, phonenumber, password,   authmodule, authdata, status, pwresetkey,    pwresetexpiry, emailoutput    db2.tblclients  not exists   (    select 1      db1.tblclients        email = db2.tblclients.email  ) 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -