Help: I want inner join 3 tables

  • I have three tables

    Table 1 has fields -> [ID] , [Person Name]

    Table 2 has fields -> [ID] , [Description]

    Table 3 has fields -> [ID] , [Created (Date&Time)] , [Actual Finish (Date&Time)] , [Category_ID] , [ClosureCode_ID] , [Employees_ID],

    [WOClassification_ID] ,[Description_ID]

    i want to inner join the three tables but not sure how to do it, i only want the Person Name from table 1, the Description from table 2 and the Created and Actual date from table 3 into one result set. I can inner join two tables like this

    SELECT Employees.ID as 'Employee ID',[Person Name], Description.ID as 'Task ID', Description.Description

    FROM Employees

    INNER JOIN Description

    ON Description.ID=Employees.ID

    ORDER BY Employees.ID

    Can anyone help me pls?

    Thank you

  • Without table DDL (including foreign key constraints), we're just guessing. But all you need to do is add another INNER JOIN clause similar to the existing one. The only question is what column in Table3 you use for the join.

    John

  • thank you john, think i got it working, just need to mess around with it. using the Employees ID from table 3 to join with Employee ID on table 3.

  • I have created 3 tables with below design and have fire inner join query.

    Table_1 = ID, Name

    Table_3 = ID, Designation

    Table_4 = ID, Reporting_to

    SELECT Table_1.ID, Table_1.name, Table_3.Designation, Table_4.Reporting_to

    FROM Table_1 INNER JOIN

    Table_3 ON Table_1.ID = Table_3.ID INNER JOIN

    Table_4 ON Table_1.ID = Table_4.ID

    Below is the result..:)

    IDnameDesignationReporting_to

    E3002196JitendraSEDBA

    E3002197MutheshSSETL

    E3002168MihirSETL

    E3002169SumitaSSETL

    E3002170EkramSEManager

    E3002171JohnyTLManager

    E3002172SurjitDBAManager

    E3002121PeterManagerSDL

  • I have three tables

    Table 1 has fields -> [ID] , [Person Name]

    Table 2 has fields -> [ID] , [Description]

    Table 3 has fields -> [ID] , [Created (Date&Time)] , [Actual Finish (Date&Time)] , [Category_ID] , [ClosureCode_ID] , [Employees_ID],

    [WOClassification_ID] ,[Description_ID]

    i want to inner join the three tables but not sure how to do it, i only want the Person Name from table 1, the Description from table 2 and the Created and Actual date from table 3 into one result set. I can inner join two tables like this

    Hi, Assuming ID is a Primary Key & Can be used as a Foreign Key...

    Select Table1.ID, Table1.PersonName, Table2.Description, Table3.CreatedDate, Table3.Actual Finish

    From Table1 InnerJoin Table2 ON

    Table1.ID = Table2.ID InnerJoin

    Table3 ON Table1.ID = Table3.ID

  • I have created three tables as per you want... and below is the query with inner join which gives you result that you want....

    SELECT Table_1.[Person Name], Table_2.Description, Table_3.[created date], Table_3.[Actual date]

    FROM Table_1 INNER JOIN

    Table_2 ON Table_1.ID = Table_2.ID INNER JOIN

    Table_3 ON Table_1.ID = Table_3.ID

    Person NameDescriptioncreated dateActual date

    Ammy adfa 2012-01-012012-05-01

    Boon sdfasdf 2012-01-062012-09-01

    Cedric lajkjasd 2012-05-012012-05-15

    David jljljasdf 2012-05-022012-03-05

    Emmy kkkasdfj 2012-05-012012-09-08

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply