How to compare data from 2 database.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sean kwok
    New Member
    • Oct 2011
    • 16

    How to compare data from 2 database.

    Hi,

    I have 2 database, One is User and the second is Data.

    In the User database there is ID, Username, Mac-Address
    In the Data database there is ID, Mac-Address

    Is there any way to match the same Mac-Address and display the Username for which Mac-address belongs to which user?

    I'm new to here not sure what addition info i have to add, if there is anything i'm required to add on feel free to tell me.

    Thanks.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You say database but you must mean table. There's no need to connect them. You already have mac address in the user table. So I see no reason to have to join to the data table.

    Comment

    • sean kwok
      New Member
      • Oct 2011
      • 16

      #3
      No i mean Database not table. 2 Database with 2 tables...

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Ok, but it doesn't matter. You already have both fields you want in the one table, why do you need to join them?

        Comment

        • vslsanthosh
          New Member
          • Feb 2012
          • 3

          #5
          select tb1.Sname,tb1.S gender from sample.t2, test.tb1 where
          sample.t2.Sno=t est.tb1.Sno

          make join on 2 database...

          Comment

          • datakeyword
            New Member
            • Feb 2012
            • 3

            #6
            Hi,sean kwok.
            There are 2 means about "cross database".
            1. 2 database on one server.
            2. 2 database on different servers.

            about 1: mysql provide the "cross database query language", please see what vslsanthosh has said. That's very clear.
            about 2: mysql dont privide this function. You must use other tools, Like "esProc", a free mass data computation tool, see here.
            here is a article about "cross database"

            Comment

            • sean kwok
              New Member
              • Oct 2011
              • 16

              #7
              Hi,

              I join the 2 database in to one, creating 2 tables now. How do i cross reference, I want to match both MACAddress and select the username to be display.

              Comment

              • sean kwok
                New Member
                • Oct 2011
                • 16

                #8
                I manage to solve it myself. Thanks for all the helps.

                Comment

                • saurav
                  New Member
                  • Feb 2012
                  • 2

                  #9
                  if you want to connect the two table from different databases and you want to show the output into another different databse
                  first you can create the one table please see the query
                  use master
                  create table life
                  (
                  name varchar(10),
                  address varchar(50),
                  )
                  insert into life values('sammy', 'usa')
                  then create the another table into another database
                  use model
                  create table line
                  (
                  name varchar(10),
                  phoneno varchar(20),
                  )
                  insert into line values('nicole' ,9089898978)

                  now use the another database
                  like tempdb

                  and join these databases

                  select * from master.dbo.life ,model.dbo.line
                  now execute this
                  but carefully don't take the different schema

                  Comment

                  Working...