Results 1 to 3 of 3

Thread: SQL joins

  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    224
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

    I am not sure which forum is the best for SQL questions. I am new to using SQL and have an error that I am sure is very simple to resolve

    I have 4 tables linked

    Code:
    			   STEP						LINK								BUG
       +---------- ST_TEST_ID				  LN_BUG_ID ------------------------> BUG_ID
    	|		  ST_ID<----------------------LN_ENTITY_ID
    	| 
    	|
    	|		  TEST
       +---------->TS_TEST_ID
    I am trying to get data from each table using Link as the main Table.

    Here is the simple code I have written

    SELECT LINK.LN_BUG_ID /*Associated.Defect ID*/ ,
    LINK.LN_ENTITY_ID /*Associated.Linked Entity ID*/,
    BUG.BG_BUG_ID /*Defect.Defect ID*/,
    BUG.BG_STATUS /*Defect.Status*/,
    STEP.ST_TEST_ID /*Test Step.Source Test*/,
    STEP.ST_ID /*Test Step.Step ID*/,
    TEST.TS_TEST_ID /*Test.Test ID*/,
    TEST.TS_NAME /*Test.Test Name*/,
    TEST.TS_EXEC_STATUS /*Test.Execution Status*/,
    TEST.TS_USER_01 /*Test.Planned Exec Start Date*/,
    TEST.TS_USER_05 /*Test.Work Stream*/

    FROM LINK
    full join Step
    full join Bug
    full join test

    on LINK.LN_BUG_ID = BUG.BG_BUG_ID and LINK.LN_ENTITY_ID = STEP.ST_ID and STEP.ST_TEST_ID = TEST.TS_TEST_ID

    I get the following error - Incorrect syntax near TS_TEST_ID

    Any help greatly appreciated

    Regards

    Mike

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    I don't know SQLServer SQL syntax, but usually you have to specify the link fields immediately after each join:

    ...
    FROM (LINK FULL JOIN BUG ON LINK.LN_BUG_ID = BUG.BG_BUG_ID) FULL JOIN (STEP FULL JOIN TEST ON STEP.ST_TEST_ID = TEST.TS_TEST_ID) ON LINK.LN_ENTITY_ID = STEP.ST_ID

  3. #3
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    224
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Hans,

    That worked, interesting that all the searches I did didn't show this as an approach.

    Many thanks.

    Mike

Posting Permissions

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