3 Replies Latest reply: Nov 16, 2012 5:17 AM by jagan mohan rao appala RSS

    How can I to join two tables from two servers?

      In MySQL, I have two different databases -- let's call them A and B.

      Database A resides on server server1, while database B resides on server server2.

      Is it possible to perform a SQL JOIN between a table that is in database A, to a table that is in database B?

        • Re: How can I to join two tables from two servers?

          Dear

           

           

          first establish the connectivity from Server1 and read the table A.

           

          then establish the connectivity from server 2 and read the table B.

          and apply the join.

           

          like,

          Connectivity server1;

           

          TableA;

          load

          ..........

          table A from server1

          ;

          connectivity from server2:

           

          Left join(TableA)

           

          load

          ......

           

          table 2 from server 2;

           

           

          Thanks,

          Mukram.

            • Re: How can I to join two tables from two servers?

              Hi Mukram,

               

              How can I make the following join "and transactions_backup.ad_id = offers.ad_id" in Tab2 and "and transactions_backup.campaign_id = campaigns.id" in Tab3? The fields names are different in case 2.

               

              Regards,

              Paula

              ---

               

               

              ODBC CONNECT TO [MySQL Servidor];

               

              Tab1:

              SELECT *

              transactions_backup.transaction_at,

              year(transactions_backup.transaction_at),

              month(transactions_backup.transaction_at),

              transactions_backup.event_type_id,

              transactions_backup.ad_id,

              transactions_backup.campaign_id id

              FROM transactions_backup

              where transactions_backup.event_type_id in (3, 13, 18)

              and transactions_backup.ad_id = offers.ad_id

               

              ODBC CONNECT TO MySQL *******;

               

              Tab2:

              JOIN (Tab1) SELECT

              offers.property,

              offers.provider,

              offers.price

              FROM offers;

               

              and transactions_backup.ad_id = offers.ad_id

               

              Tab3:

              JOIN (Tab1) SELECT

              FROM campaigns

              WHERE campaigns.campaign_type = 4;

               

              and transactions.campaign_id = campaigns.id

                • Re: How can I to join two tables from two servers?
                  jagan mohan rao appala

                  Hi,

                   

                  Try this script

                   

                   

                  ODBC CONNECT TO [MySQL Servidor];

                   

                  Tab1:

                  SELECT *

                  transactions_backup.transaction_at,

                  year(transactions_backup.transaction_at),

                  month(transactions_backup.transaction_at),

                  transactions_backup.event_type_id,

                  transactions_backup.ad_id AS AdID,

                  transactions_backup.campaign_id  AS CampaignID

                  FROM transactions_backup

                  where transactions_backup.event_type_id in (3, 13, 18)

                  and transactions_backup.ad_id = offers.ad_id

                   

                  ODBC CONNECT TO MySQL *******;

                   

                  Tab2:

                  JOIN (Tab1) SELECT

                  offers.ad_id AS AdID

                  offers.property,

                  offers.provider,

                  offers.price

                  FROM offers;

                   

                  Tab3:

                  JOIN (Tab1) SELECT

                  campaigns.id as CampaignID,

                  *

                  FROM campaigns

                  WHERE campaigns.campaign_type = 4;

                   

                  Hope this helps you.

                   

                  Regards,

                  Jagan.