Professional Web Applications Themes

how to joun 2 db in one? - MySQL

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....

  1. #1

    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.

    mario.lat_ Guest

  2. #2

    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.
    Bill Karwin Guest

  3. #3

    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.
    mario.lat_ Guest

  4. #4

    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.
    Bill Karwin Guest

  5. #5

    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:

    [url]http://dev.mysql.com/doc/refman/5.0/en/federated-storage-engine.html[/url]

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

    Greetings
    Kai

    --
    This signature is left as an exercise for the reader.
    Kai Ruhnau Guest

  6. #6

    Default Re: how to joun 2 db in one?

    "mario.lat_" <mario.latlibero.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:

    [url]http://dev.mysql.com/doc/refman/5.0/en/federated-storage-engine.html[/url]

    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: [url]http://dev.mysql.com/doc/refman/5.0/en/[/url]
    MySQL User Forums: [url]http://forums.mysql.com/[/url]
    Axel Schwenke Guest

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139