Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Understanding what an inner join query produces

Understanding what an inner join query produces

Scheduled Pinned Locked Moved Database
helpdatabasequestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Steve Holdorf
    wrote on last edited by
    #1

    Below is a multi inner join query that works. The problem is that I don't understand how it is evaluated and need help understanding what it is doing. Can someone explain in detail what the query is doing because I don't quite understand? SELECT DISTINCT o.OrderDate, c.CompanyName, od.Quantity, p.ProductName FROM Customers AS c INNER JOIN Orders AS o ON o.CustomerID = c.CustomerID INNER JOIN [Order Details] AS od ON od.OrderID = o.OrderID INNER JOIN Products AS p ON p.ProductID = od.ProductID Thanks, Steve Holdorf

    M L N 3 Replies Last reply
    0
    • S Steve Holdorf

      Below is a multi inner join query that works. The problem is that I don't understand how it is evaluated and need help understanding what it is doing. Can someone explain in detail what the query is doing because I don't quite understand? SELECT DISTINCT o.OrderDate, c.CompanyName, od.Quantity, p.ProductName FROM Customers AS c INNER JOIN Orders AS o ON o.CustomerID = c.CustomerID INNER JOIN [Order Details] AS od ON od.OrderID = o.OrderID INNER JOIN Products AS p ON p.ProductID = od.ProductID Thanks, Steve Holdorf

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      There used to be a good article on CP explaining join types but I couldn't find it, this returns[^] what should help Basically an inner join returns records that have the same values in the tables on each side of the join. Orderdetail => product There will be a foriegn key constraint on the OD table that says an orderid cannot be entered unless there is a product record, therefore this join will no do any filtering but will be used as a lookup to get the productname for each orderdetail. Order => Orderdetail This gets the detail records for each order record and will be a 1 to many join. Customer => Order is the same as order/detail join

      Never underestimate the power of human stupidity RAH

      1 Reply Last reply
      0
      • S Steve Holdorf

        Below is a multi inner join query that works. The problem is that I don't understand how it is evaluated and need help understanding what it is doing. Can someone explain in detail what the query is doing because I don't quite understand? SELECT DISTINCT o.OrderDate, c.CompanyName, od.Quantity, p.ProductName FROM Customers AS c INNER JOIN Orders AS o ON o.CustomerID = c.CustomerID INNER JOIN [Order Details] AS od ON od.OrderID = o.OrderID INNER JOIN Products AS p ON p.ProductID = od.ProductID Thanks, Steve Holdorf

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Mycroft is referring to this[^] article.

        I are Troll :)

        M 1 Reply Last reply
        0
        • L Lost User

          Mycroft is referring to this[^] article.

          I are Troll :)

          M Offline
          M Offline
          Mycroft Holmes
          wrote on last edited by
          #4

          Thanks Eddy, that is exactly the article I was after, have to bookmark it for future reference.

          Never underestimate the power of human stupidity RAH

          L 1 Reply Last reply
          0
          • M Mycroft Holmes

            Thanks Eddy, that is exactly the article I was after, have to bookmark it for future reference.

            Never underestimate the power of human stupidity RAH

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            You're welcome :)

            1 Reply Last reply
            0
            • S Steve Holdorf

              Below is a multi inner join query that works. The problem is that I don't understand how it is evaluated and need help understanding what it is doing. Can someone explain in detail what the query is doing because I don't quite understand? SELECT DISTINCT o.OrderDate, c.CompanyName, od.Quantity, p.ProductName FROM Customers AS c INNER JOIN Orders AS o ON o.CustomerID = c.CustomerID INNER JOIN [Order Details] AS od ON od.OrderID = o.OrderID INNER JOIN Products AS p ON p.ProductID = od.ProductID Thanks, Steve Holdorf

              N Offline
              N Offline
              Not Active
              wrote on last edited by
              #6

              A very good reference book for this subject is Inside Microsoft® SQL Server® 2008: T-SQL Querying[^]


              only two letters away from being an asset

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups