title: How to Filter INNER JOIN SQL Command Results
body: <p>I have a table which records form submissions.  For each submission of the form there are the following variables:</p>
  
  <pre><code>userid
  record
  accountName
  accountNumber
  </code></pre>
  
  <p>When a user submits the form, the table is populated with a <code>record</code> value on each line item.  In other words, the values are all commonly linked by the <code>record</code> value.  I am trying to user <code>INNER JOIN</code> to filter the results onto a table that displays the <code>userid</code>, <code>accountName</code> and <code>accountNumber</code> as columns.  I am very close with this command:</p>
  
  <pre><code>SELECT t1.value AS number, t2.value AS name, t3.value AS userid
  FROM mytable AS t1
  INNER JOIN mytable AS t3
  INNER JOIN mytable AS t2 ON t1.record = t2.record
  WHERE t1.name = 'addAccountNumber'
  AND t2.name = 'addAccountName'
  AND t3.name = 'userid'
  </code></pre>
  
  <p>The only problem is that the results are not being limited to one per entry.  It appears that multiple instances are being shown on the table.</p>
  
  <p>I believe there needs to be some editing around the <code>WHERE</code> portion of the statement.  It seems to me that the results are not picking up on the name values and filtering the results.  Any suggestions on how to resolve this?</p>
  
  <hr>
  
  <p>UPDATED:  </p>
  
  <p>I should add that I do get the proper filtering results when I only include two rows in the call as seen here:</p>
  
  <pre><code>SELECT t1.value AS accountNumber, t2.value AS accountName
  FROM mytable AS t1
  INNER JOIN mytable AS t2
  ON t1.record=t2.record WHERE t1.name='addAccountNumber' AND t2.name='addAccountName'
  </code></pre>
  
  <p>Thought that may help show what I am coming from.  So, in general it is something to do with adding the <code>userid</code> variable that is giving me the trouble</p>