Menu

#175 (ok 4.1.0) (Relation) Cross DB relations

Needs_planning
fixed
nobody
5
2013-12-12
2002-05-03
Anonymous
No

I've just started working with relatons within phpMyAdmin. I'm
going to implement the table within all my databases.

One thing
that I do is use indexes to other databases on the same server. My
reasoning (which may be flawed, I admit) is that I can organize by
basic feature of my intranet via database and put details into
individual tables.

For instance, I'm working on an IT database
for managing everything to do with all the computers in our
facility. One column in the main computer table is a link to the
employees table, indicating who the primary user of that machine
is. Of course, the employees table is in the HR database, and not the
IT database. So being able to do referential checks is not currently
possible (as far as I can find so far) within the current
implementation.

Thanks,
Michael

Discussion

  • Marc Delisle

    Marc Delisle - 2002-05-03
    • summary: Cross DB relations --> (Relation) Cross DB relations
     
  • Anonymous

    Anonymous - 2002-05-28

    Logged In: YES
    user_id=509287

    hmm the join syntax as described in the MySQL Manual
    doesn't show how to do a join between tables in different
    databases and i used to be sure there is no way to do that.
    Can you do a LEFT JOIN between tables which are not in the
    same db??

     
  • Nobody/Anonymous

    Logged In: NO

    Yes. It's in the section on naming tables. As long as it's on the same
    server, a table (or a column, for that matter) in a different DB can be
    accessed by prefixing the DB name and a dot. For instance, databases
    A and B with tables T1 (cols c1 & c2) and T2 (cols c3 & c4) respectively,
    working in A:

    SELECT c1, c2, c3 FROM T1 LEFT JOIN B.T2 ON
    T1.c1 = B.T2.c4

    (not tested, but very similar to syntax I've been
    using successfully for about 6 months.)

     
  • Garvin Hicking

    Garvin Hicking - 2003-03-05
    • labels: --> Relations,Comments,History,...
    • milestone: --> Needs_planning
    • status: open --> open-later
     
  • Marc Delisle

    Marc Delisle - 2013-04-20

    Indeed, but it depends on how much time you think it will require.

     
  • Michal Čihař

    Michal Čihař - 2013-06-11
    • Status: open-later --> open
     
  • Isaac Bennetch

    Isaac Bennetch - 2013-06-26
    • labels: Relations,Comments,History,... --> Relations, Comments, History, ...
    • summary: (Relation) Cross DB relations --> (ok 4.1.0) (Relation) Cross DB relations
    • Description has changed:

    Diff:

    
    
    • status: open --> resolved
     
  • Marc Delisle

    Marc Delisle - 2013-12-12
    • Status: resolved --> fixed