I'm trying to figure the best way to combine the results from 2 different DBs on 2 different servers. I'd use a union if they were in the same DB but I'm thinking the way to go is to match up the column names and then merge the results together into a standard array.
So a)Is this the best way to go about it and b) what's the best way to do it?
Any help would be appreciated.
Thanks, Chris
LifeinAsia
5:58 pm on May 13, 2009 (gmt 0)
It depends on the DB you're using. With MS SQL you can setup a linked server, which would allow you to use UNION like usual. You'd just have to fully qualify the table on the linked server. Instead of TableName, you'd need to specify something like [LinkedServerName].DatabaseName.[dbo].TableName
[edited by: LifeinAsia at 5:58 pm (utc) on May 13, 2009]
surfgatinho
6:02 pm on May 13, 2009 (gmt 0)
Sorry, should have said. I'm running MySQL
LifeinAsia
6:56 pm on May 13, 2009 (gmt 0)
No idea if you can do that in MySQL.
Alternatively, maybe you can do something where one server automatically replicates the data to the other server?
Otherwise, it's probably easier to just "unionize" the data on the PHP side.
coopster
7:13 pm on May 13, 2009 (gmt 0)
You could always set up a script on the remote server that sends the formatted data to you or perhaps pull it from the local server. comma-separated value, tab-separated, xml, etc.