SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Splitting Queries

    hi, we're working on a project where different mysql databases are stored on separate computers.
    is there a way to breakdown queries such as join statements into queries concerning only a particular database?

    For example, a query with table1 JOIN table2 (table1 and table2 are from different databases), how are we be able to do this?

    Any help would be greatly appreciated.

  2. #2
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I'm not 100% sure, but I think you can do something like this:

    Code:
    SELECT * FROM db_1.table_a as a
      INNER JOIN db_2.table_b as b ON b.field = a.field
    Edit:

    I just realized that my query will probably only work when the databases are located on the same server.
    ERIK RIKLUND :: Yes, I've been gone quite a while.

  3. #3
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks lilleman. but you're right. What we need is to query different databases on different servers.

    Again, more help would be greatly appreciated.

  4. #4
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it seems that no one is replying to my thread. does this mean that what we're trying to do is near impossible?

    please, we really need help..

  5. #5
    SitePoint Evangelist ghurtado's Avatar
    Join Date
    Sep 2003
    Location
    Wixom, Michigan
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I believe that unless you have the two Databases in the same server, so that both can be accessed through the same connection, and thus be used in the same query (as lilleman stated), you will not be able to query two servers in one query. Your only solution is to set up a way to synchronize the servers so that at least one of them always contains all the tables you need to query from.
    Garcia


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
  •