Resolved SQL question
- How-to
- Rick Domogalik
- PowerBuilder
- Wednesday, 20 November 2019 04:01 PM UTC
I have 3 tables.
Table 1
DOC_ID
Table 2
DOC_ID
KEYWORD
Table 3
VIEW_ID
KEYWORD
I am using 3 tables to retrieve a view of data based on what the user defines. Kind of like a speed-dial or favorite. The user can define what "keywords" will determine what will appear in the view they define. The first table is a list of documents in the system. These documents can have 0, 1 or many keywords added to them. These keywords are stored in Table 2. The 3rd table is a list of keywords for the view the user has defined. I have a treeview that when the user clicks on the view it retrieves a doc list on the right based on the keywords defined for the view.
The problem I am having is how to JOIN Table 1 to 2. When I join them, it duplicates the rows from table 1 for each keyword added to table 2.
I feel like I am missing something simple, but have been staring at this for days.
I tried building a temp table and testing each doc to see if it meets the view criteria, but there are thousands of documents and the function was incredibly slow and will not be acceptable to users. I have also looked at "Exists". This seems to be the way to go to do a quick retrieval, but I still get duplicates.
Hoping someone has done a retrieval like this and can point me in the right direction.
Thanks.
Rick
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.