SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    May 2001
    Location
    Germany
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php and mysql: joins over tables in two or more databases?

    For a bigger project it is necessary to do queries over tables of two (or even more) databases, located at different servers.

    Is this possible, and how can I do this.

    Any help is appreciated.
    Thank you,
    Christoph
    http://www.filsca.com

  2. #2
    SitePoint Wizard Aes's Avatar
    Join Date
    Jun 2001
    Location
    Oklahoma
    Posts
    3,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I do not believe that is possible; PHP and MySQL can only have one database connection alive at a time, so while you can have multiple tables joined with one query, you'll have to reconnect to retrieve or modify data located over multiple databases.

    It would be nice if they could figure out a way to effeciently do this though; perhaps in future release of MySQL?
    Colin Anderson
    Ambition is a poor excuse for those without
    sense enough to be lazy.

  3. #3
    SitePoint Member
    Join Date
    May 2001
    Location
    Germany
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you Colin, although the answer is not really what I hoped for

    Could one find a workaround by using temp tables - making one temp table of the fields needed from the one server, then connecting to the other server, creating another temp table from the first table and joining this one with the tables necessary from the second server?
    Or other the data lost once the the other database is connected?
    Is it possible with other databases then? PostgreSQL?

    Cheers,
    Christoph

    Originally posted by Aes
    I do not believe that is possible; ...

  4. #4
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you CAN join tables from multiple DBs very easily, but NOT when they're located on different servers. and that's what you're talking about right?
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR


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
  •