Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2004
    Posts
    6

    Question Unanswered: Is this possible

    I want to join tables from 2 different databases.
    I have a table in 1 db in which i want to join with in another table in abother db.

    Can this be done and what is the syntax?
    Thanks
    Rich

  2. #2
    Join Date
    Feb 2004
    Posts
    7
    INSERT INTO `dbname1`.`table1` (row1,row2)
    SELECT row1,row2 FROM `dbname2`.`table2`
    WHERE row1 > 5;

    would be an example.

    - John

  3. #3
    Join Date
    Sep 2002
    Location
    Montreal, Canada
    Posts
    224
    Provided Answers: 1
    Quote Originally Posted by thesandman
    I want to join tables from 2 different databases.
    I have a table in 1 db in which i want to join with in another table in abother db.

    Can this be done and what is the syntax?
    Thanks
    Rich
    You just need to prefix the tablename with the database name, for example:

    select a.col1, b.col2
    from database1.tablename a
    inner join database2.tablename b on (a.id=b.id)
    where b.col2 = 33

Posting Permissions

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