title: Visual FoxPro Query
body: <p>We are attempting to modify a process in our system and I am unable to come up with a query that would retrieve the correct data.  The system currently retrieves data from a terms table using the <code>titlekey</code> from the author info table, meaning all authors have the same terms.  We want to be able to add specific terms for an author, cut still allow other authors to use the terms associated with the title.  I'm not sure what <code>SQL</code> would retrieve the proper term row based on the author row.</p>
  
  <p>My thought was to add an author column to the terms table.  For row 2 in the author info table we would like row 2 retrieved from the term table.  But for rows 1 and 3 in the author table we would like row 1 retrieved from the term table.  This would be a parameterized view.  Is it possible to have one query perform the retrieval?  If so can you provide a `FoxPro SQL` sample?</p>
  
  <p>Example:  </p>
  
  <p>Table of author info:  </p>
  
  <pre><code>
  <b>   Key    AuthorKey    TitleKey</b>  
     ---    ---------    --------  
      1         1           1  
      2         2           1  
      3         3           1   
  </code></pre>  
  
  <p>Table of terms:</p>
  
  <pre><code>
  <b>   Key    AuthorKey    TitleKey   Term</b>
     ---    ---------    --------   ----  
      1         0           1       .50  
      2         2           0       .60  
  </code></pre>
  
  <p>Given Author key 2 and Title key 1, row 2 in the author info table, we would like the .60 term returned from the table of terms.</p>
  
  <blockquote>
    <p>I apologize if I wasn't clear so here is an example using the mock tables above.  </p>
  </blockquote>
  
  <p>If I set the titlekey view parameter to 1 and the authorkey viewparamter to 2 I would like .60, term key of 2, to be retrieved.  </p>
  
  <p>If I set the titlekey view parameter to 1 and the authorkey viewparamter to 3 I would like .50, term key of 1, to be retrieved.</p>