Forum Moderators: coopster

Message Too Old, No Replies

Insert/ Append on Database. HOW?

its likely backuping database :)

         

khaki monster

1:28 pm on Feb 28, 2006 (gmt 0)

10+ Year Member



actually these is more likely backuping a database... for my Small CMS intend to our school campus("for some local News and Update").

i'd like to copy a table contents from one database to another database like the statement below. given all connection are working.

code:
INSERT INTO newDatabase.newTable SELECT * FROM Database.Table

now, my confusion is how would i insert/ append another batch of data from "Database.Table" to "newDatabase.newTable"?
with accurate and quick process. coz i think the above SQL statement is a bit sloppy and slow. though im not sure with that theory :)

any other tips or technique aside from mysqldump and mysqlhotcopy for backuping are also appreciated.

coopster

2:09 am on Mar 2, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



If the database is on the same server and you have authority to both databases you should be good to go. Are you using MySQL? If so, have a look at the INSERT ... SELECT [dev.mysql.com] syntax.

khaki monster

2:42 pm on Mar 4, 2006 (gmt 0)

10+ Year Member



yes... im using MySQL and all of my database's is on the same server.

do i have to log to both of database when using INSERT..SELECT?

coopster

5:06 pm on Mar 4, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



No. You need to make a connection to one of them though to get a resource handle with mysql_connect. Just be sure to qualify your files with 'database.table' sytanx.