Joining tables

Discussion in 'SQL Server' started by T.Raj, Nov 28, 2008.

  1. T.Raj

    T.Raj New Member

    Joined:
    Nov 28, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi,
    I have 3 tables
    Table A
    Emp_Name
    Emp_ID
    Task_Type

    Table B
    Task_Id
    Task_Type

    Table C
    TaskDescription_Id
    TaskDescription
    Task_Id


    Instead of values for Task_Type and TaskDescription i want to have their ID in Table D with Emp_Name, Emp_ID, Task_Id, TaskDescription_Id

    I tried inner , left outer join but but it does not give me the correct value

    SQL statement is

    Select A.Emp_Name, A.Emp_ID, B.Tak_Id, C.TaskDescirption_Id from Table A
    left outer join Table B on A.Task_Type = B.Task_Type
    left outer join Table C on B.Task_Id = B. Task_Id

    What am'i doing wrong?
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    I don't understand the question. What's the relevance of Table D?
    What are you trying to do, create a table or run a query? Or both, i.e. are you doing create table d as select...?
    If a query, what columns do you want the query to display?
     
  3. T.Raj

    T.Raj New Member

    Joined:
    Nov 28, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi,
    I'm trying to upload data from an old database to new database and we are using ID's into the main table for some of the standard value like TABLE B and TABLE C which will have some standard values records.
    I have copied these old standard tables without ID numbers to new tables with ID numbers. Now i'm trying to copy the main tables where i have these standard values in some of the records instead of the values i want to compare the values and get the ID from TABLE B and TABLE C
     
  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    I still don't clearly understand the basic goal you're trying to achieve. Could you give a couple of example rows for each relevant table, and what data you want to end up where?

    Does table D contain the "old" data that tables A-C now contain in the new format (with IDs)?
    If not, what tables exist in the old format?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice