Unix Technical Forum

how to joun 2 db in one?

This is a discussion on how to joun 2 db in one? within the MySQL forums, part of the Database Server Software category; --> Hallo, I'd like to join 2 db in one: I'd like to do query dealing the 2 db. I'd ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 07:44 AM
mario.lat_
 
Posts: n/a
Default how to joun 2 db in one?

Hallo,
I'd like to join 2 db in one:
I'd like to do query dealing the 2 db.

I'd like to Join these db only for some querues and I want that these 2 db
are separated and continue to be separated.

For example I have DbA and DbB.
in DbA there is table: cities (name,state)
in DbB there is table: person (name, city)

I'd like, for example, query:
SELECT DbB.person.name , DbA.cities.state FROM
DbA.cities.name=DbB.person.city


How can I do?
Thank You in avance.
Mario.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 07:44 AM
Bill Karwin
 
Posts: n/a
Default Re: how to joun 2 db in one?

mario.lat_ wrote:
> I'd like, for example, query:
> SELECT DbB.person.name , DbA.cities.state FROM
> DbA.cities.name=DbB.person.city


Yes, MySQL supports database specifiers in the FROM clause, but the
syntax is different from what you use above.

Here is what I would write:

SELECT B.person_name, A.state
FROM DbA.cities AS A JOIN DbB.person AS B
ON A.name = B.city

Regards,
Bill K.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 07:46 AM
mario.lat_
 
Posts: n/a
Default Re: how to joun 2 db in one?

Thank you for answering me.
But if 2 database are on different machine?
It is possible to something like that? how?
Thank you for your help.
Mario.

> mario.lat_ wrote:
>> I'd like, for example, query:
>> SELECT DbB.person.name , DbA.cities.state FROM
>> DbA.cities.name=DbB.person.city

>
> Yes, MySQL supports database specifiers in the FROM clause, but the
> syntax is different from what you use above.
>
> Here is what I would write:
>
> SELECT B.person_name, A.state
> FROM DbA.cities AS A JOIN DbB.person AS B
> ON A.name = B.city
>
> Regards,
> Bill K.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 07:46 AM
Bill Karwin
 
Posts: n/a
Default Re: how to joun 2 db in one?

mario.lat_ wrote:
> Thank you for answering me.
> But if 2 database are on different machine?
> It is possible to something like that?


No, a given MySQL instance can access only databases that are on the
same host.

Regards,
Bill K.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-28-2008, 07:46 AM
Kai Ruhnau
 
Posts: n/a
Default Re: how to joun 2 db in one?

mario.lat_ wrote:
> But if 2 database are on different machine?
> It is possible to something like that? how?
> Thank you for your help.


Take a look at the federated storage engine:

http://dev.mysql.com/doc/refman/5.0/...ge-engine.html

It was implemented to allow references to tables at other MySQL instances.

Greetings
Kai

--
This signature is left as an exercise for the reader.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-28-2008, 07:46 AM
Axel Schwenke
 
Posts: n/a
Default Re: how to joun 2 db in one?

"mario.lat_" <mario.lat@libero.it> wrote:

> But if 2 database are on different machine?
> It is possible to something like that? how?


Beginning with version 5.0.3 MySQL supports the FEDERATED table engine:

http://dev.mysql.com/doc/refman/5.0/...ge-engine.html

Using it you can access remote MySQL tables as if it was a local table.
FEDERATED tables still have a lot of limitations and are not
particularly fast. Maybe it is good enough for your needs.


XL
--
Axel Schwenke, Senior Software Developer, MySQL AB

Online User Manual: http://dev.mysql.com/doc/refman/5.0/en/
MySQL User Forums: http://forums.mysql.com/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:23 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com