2

Is there a way to insert data from a table in schema1 to a table in schema2 in mysql.

Also , I assume there will be any access/privilege issues.

My environment is Joomla using Fabrik extension, PHP, MySQL

Kindly share some tips

Thanks in advance

kelly
  • 183
  • 1
  • 4
  • 11

2 Answers2

1

You can always preface the table name with the database name and as long as the user has the appropriate permission you can do:

insert into db1.users( first, middle, last )
select a.first, a.middle, a.last from db2.users a

See the following for the documentation insert .. select

Wes
  • 6,455
  • 3
  • 22
  • 26
1

This query does that:

INSERT INTO db2.table1 SELECT * FROM db1.table1;
  • Not tested but should do the job.

If you do this as root user, you will have no permission issues.

  • Backup your data first, though.
Stephane Gosselin
  • 9,030
  • 5
  • 42
  • 65
  • Then you just have to make sure the user you use has access to both databases. If it is not the same user, you can still do it through a oneliner shell script, if you are on linux. Just msg me back if you are stuck. – Stephane Gosselin Jun 03 '11 at 05:27