1

I want to access table of another database from my current database. For example, I have created a database 'manager' and I want access to the table 'emp' which is in database 'employee'.

It is hosted by same server.

How can I do this?

Vipul Kumar
  • 67
  • 3
  • 11
  • Both database are hosted in same domain or different – kannan Oct 18 '15 at 05:02
  • Same MySQL Server instance: `USE \`manager\`; SEEECT \`column0\` FROM \`employee\`.\`emp\`;`. In another case, one option is: [15.8 The FEDERATED Storage Engine](http://dev.mysql.com/doc/refman/5.6/en/federated-storage-engine.html). – wchiquito Oct 18 '15 at 05:08

1 Answers1

4

If you are talking about a database on another host, you can't do that in mysql. If it is another database on the same host, on the same mysql instance, prefix the table name with the database name, ie

Select * from myotherdb.sometable

I believe that you can use this notation for joins, etc as long as you prefix the table names with the database name.

If you need to access another database instance, you will need to connect to it separately. You won't be able to make cross db joins.

Some other dbmses have functions like oracle's database links, which allow to do things like make a table or view accessible to another database on another host.

JoSSte
  • 2,953
  • 6
  • 34
  • 54