1

Topic: insert data in mysql

I have :
Database 1, Table A with field a, b, c, d
Database 2, Table A with field a, b, c, d, e, f, g

May i know how to extract the data of field a, b, c, d of Database 1 into Database 2's a, b, c, d field, using mysql query?

Re: insert data in mysql

SELECT a, b, c, d INTO db2.tableA FROM db1.tableA

Should do?

3

Re: insert data in mysql

elbekko, thank you thank you.... i try it out now...

i read up the tutorials of mysql but somehow all those things won't go into my head, i just can't sort it out, those commands are driving me crazy :-(

Re: insert data in mysql

Don't worry, it' isn't all that hard, but things like these can be confusing (I had to think twice too tongue).

5

Re: insert data in mysql

got error...

SQL query: Documentation

SELECT id, username,
PASSWORD , url, icq, msn, aim, yahoo, signature, timezone, num_posts, last_post, registered, last_visit, location, email, email_setting
INTO database2.users
FROM database1.users
LIMIT 0 , 30

MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'database2.users FROM database1.users
LIMIT 0, 30' at line 1

Re: insert data in mysql

Moved to Programming

http://dev.mysql.com/doc/refman/5.0/en/ … table.html
so this should work

insert into db2.tableA (a,b,c,d) SELECT a, b, c, d FROM db1.tableA

7

Re: insert data in mysql

Thank you Smartys!
I just got it work before reading your reply. :-)

Now i just need to see if all the data would be matching/linking each others after inserting to the db2.

That's the only way i can do to import data into the forum tables since i can't write a complicated scripts.