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 titlekey 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 SQL would retrieve the proper term row based on the author row.
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?
Example:
Table of author info:
Key AuthorKey TitleKey
--- --------- --------
1 1 1
2 2 1
3 3 1
Table of terms:
Key AuthorKey TitleKey Term
--- --------- -------- ----
1 0 1 .50
2 2 0 .60
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.
I apologize if I wasn't clear so here is an example using the mock tables above.
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.
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.