August 29th, 2002, 05:03 PM
Join across databases
I'm working on a project using mSQL and PHP (yes, Msql)...
The support for this database is not that great, and I love the devshed so...
i wish to extract a large block of text, around 1100 characters, from a table in one database, that table consists of a field linked to another table in another database.
my questions are:
1) is it possible to query across dbs???
2) is a better db design to put the table to be queried in the database that contains the linked table???
August 30th, 2002, 08:11 PM
Assuming that they are under the same mysql connection then this is not a problem.
select a.column_a, b.column_b from database_one.table_name as a inner join
database_two.table_name as b on a.some_column=b.some_column
August 31st, 2002, 01:39 PM
the database is
MiniSQL (mSQL) not mySQL...
it should be the same. right??
i suspected the syntax would be similar to a regular join... just use the "dot" operator???
i'll try it.. thanks Onslaught!!
how about the second question? what's your take on that?
Last edited by justin_dago; August 31st, 2002 at 01:42 PM.
September 1st, 2002, 02:50 PM
Sorry, missed the missing y. In theory it should be the same though.
In reality, the way most of RDBMS use the term databases are just a replacement for the term schema. Because all of the data is stored in the same location it is easily accessible across different "databases" as long as your have appropriate rights granted to access each area needed.
I personally think you should leave them in the most reasonable design possible. If this means seperate databases/schemas then so be it. I do this quite often in both DB2 and MySQL.