Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2009
    Posts
    7

    Unanswered: Jining two tables of different grainularity

    I have two tables.

    Table A: Has an ID field in it. (ID is a PK here)
    Table B Has an ParentID in it. (It also has it's own PK that is ID)

    These tables are not joined together. Right now they are stand alone tables in the Database.

    But

    The scenario is the ParentID field in Table B is same as ID field in Table A i.e.

    Table A.ID = Table B.ParentID

    How to join them? Any help please. Thanks

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by AijazAhmed
    How to join them? Any help please. Thanks
    like this --
    Code:
    SELECT ...
      FROM tableA
    INNER
      JOIN tableB
        ON tableB.ParentID = tableA.ID
    pretty easy, innit
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Nov 2004
    Posts
    1,427
    Provided Answers: 4
    Quote Originally Posted by AijazAhmed
    These tables are not joined together. Right now they are stand alone tables in the Database.
    How do joined tables in the Database look like and how do you create them?
    With kind regards . . . . . SQL Server 2000/2005/2012
    Wim

    Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
    Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by Wim
    How do joined tables in the Database look like and how do you create them?
    one of them has a primary key, and the other has a foreign key that references it

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Oct 2009
    Posts
    7
    Quote Originally Posted by Wim
    How do joined tables in the Database look like and how do you create them?
    They are not joined in the database. They are just capturing a raw data there. Thi DB is a vendor supplied one.
    I need to to create a data mart from three dBs like these.
    Thanks

  6. #6
    Join Date
    Nov 2004
    Posts
    1,427
    Provided Answers: 4
    Quote Originally Posted by r937
    one of them has a primary key, and the other has a foreign key that references it

    Are they valuable? I have lots of those. The "others" even have primary keys too.
    With kind regards . . . . . SQL Server 2000/2005/2012
    Wim

    Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
    Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages

Posting Permissions

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