Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2005
    Posts
    5

    Unanswered: need help creating outer join on multiple tables

    I'm trying to join 3 tables in an outer join since I am loosing records that need to be included if I only use an inner join. I am pulling data from an MSDE database using the microsoft query tool.

    The problem is that I get the message that I can't use an outer join on a query with more than 2 tables, but that can't be right can it?

    I'm a SQL code novice so any help would be greatly appreciated!

    SELECT
    Article.articleId
    , Article.articleName
    , Article.articleStatus
    , Articlegroup_2.ArticlegroupId
    , Articlegroup_2.g2_key
    , Articlegroup_2.g2_name
    , articleGroup.articleGroupId
    FROM
    HIP.dbo.Article Article, HIP.dbo.articleGroup articleGroup, HIP.dbo.Articlegroup_2 Articlegroup_2
    WHERE
    articleGroup.articleGroupId = Article.articleGroupId AND
    Article.articleGroupId2 = Articlegroup_2.Articlegroup_2_Id

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Code:
        SELECT a.articleId
    	 , a.articleName
    	 , a.articleStatus
    	 , g2.ArticlegroupId
    	 , g2.g2_key
    	 , g2.g2_name
    	 , a.articleGroupId
          FROM HIP.dbo.Article a
     LEFT JOIN HIP.dbo.articleGroup g
    	ON a.articleGroupId = g.articleGroupId
     LEFT JOIN HIP.dbo.Articlegroup_2 g2
    	ON a.articleGroupId2 = g2.Articlegroup_2_Id
    Last edited by Brett Kaiser; 11-02-05 at 16:50.
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Nov 2005
    Posts
    5
    I just tried using that code and get the following message

    "Could not add the table 'HIP.dbo.article'."

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Where are you doing this from?

    Start Query Analyzer and do this there.

    I also modified the code slightly
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  5. #5
    Join Date
    Nov 2005
    Posts
    5
    I don't have Query Analyzer installed. I'm using a tool called Microsoft Query. It's a tool that gets fired up when you reference an external datasource when creating a pivot table in Excel and want to edit the query.

  6. #6
    Join Date
    Nov 2005
    Posts
    5
    Hi Brett,

    Thanks...I got it to work using the code you wrote....turns out there was a connection failure. Appreciate the help!

Posting Permissions

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