title: SQL SERVER 2008 - joins
body: <p>I have three tables that I'm trying to join to get the necessary data. Here they are...</p>
  
  <pre><code>*TblComp*        *TblCompParent*         *tblCompProcesses*
  CompID            CompBillingID           CompID
  CompBillingID     Capacity1               CompProcessID
                    Capacity2
  </code></pre>
  
  <p>So what I'm trying to do with these three tables is....</p>
  
  <pre><code>Select tblCompParent.Capacity1, tblCompParent.Capacity2, CompProcessID
  </code></pre>
  
  <p>My problem is this...In tblComp there are 351 values - so i start off by joining tblComp and tblCompparent and SELECTING tblCompparent.capacity1, tblcompparent.capacity2, the query looks like this...</p>
  
  <pre><code>SELECT dbo.tblComp.CompID, dbo.tblCompParents.Capacity1, dbo.tblCompParents.Capacity2
  FROM dbo.tblCompParents INNER JOIN
  dbo.tblComp ON dbo.tblCompParents.CompBillingID = dbo.tblComp.CompBillingID
  </code></pre>
  
  <p>And this works fine, it's when I try to join tblCompProcess to pull the CompProcessID is when I get like 580 records. I'm not sure what can of join I have to do on tblCompprocess to select only one CompProcessID per compID.</p>
  
  <p>And it seems like i have to use tblComp otherwise I'll have no way of joining tblCompProcess.</p>
  
  <p>EDIT1:</p>
  
  <pre><code>SELECT dbo.tblComp.CompID, dbo.tblCompParents.Capacity1, dbo.tblCompParents.Capacity2, tblCompProcess.compprocessID
  FROM dbo.tblCompParents INNER JOIN
  dbo.tblComp ON dbo.tblCompParents.CompBillingID = dbo.tblComp.CompBillingID
  Inner Join dbo.tblCompprocess on tblCompProcess.CompID = tblComp.CompID
  </code></pre>