Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Inquiring MIND wants to know... query from 2nd database?


grwd

Recommended Posts

Posted

:?: If in a PHP document I wanted to query a mysql table in another database on the same server (say 'customer ' table with fld1, fld2 and fld3 in 'my_other_db' database.) --- What would the PHP code and query look like?

 

Inquiring MIND wants to know... :shock:

Thank you,

Tim

Posted

Tim,

 

The first thing you have to do is connect to the other databse, then would be your query. and then your output.

 

There are some very good php/mysql tutorials at Sitepoint.com

Posted

I know this works for Oracle, so I see no reason why it should not work for mysql.

 

The easiest way to do it is to create a database link from your source database to the destination database. This link will have the connect info and also you can set it up so it is only allowed to read from specific tables on the new database.

 

Ex: DB1 & DB2

Link called DB1_to_DB2 will be created on DB1 to read a table - USERS on DB2

 

Query: Select * from USERS@DB1_to_DB2;

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...