Hi, I have basic tables one and two. Let`s call them tbl1 and tbl2.
tbl1
---------
1 - apple |
2 - orange |
3 - banana |
4 - pineapple
tbl2
---------
1 - table |
2 - chair |
3 - sofa |
Then there is tbl3 that has foreign keys that link it to both tables above.
Table 3 form has two select fields: one that queries tbl1 and another that queries tbl2. So far, so good. I combine items from tbl1 and tbl2 in tbl3.
Then I have the following situation: When users fulfill tbl3, I want the select2 (corresponding to data from tbl2) to reload after the user has picked an item from tbl1. What for?
Let`s say that for the first time fulfilling tbl3 the user has picked "apple" from tbl1 and "sofa" from tbl2. When the user selected "apple", the second dropdownlist reloaded with all the 3 items as options.
Now, the second time the user fulfills a tbl3 form, if the user selects "apple" again, he will now have only 2 options. apple AND sofa have been picked before. Options now are only "table" and "chair". If he picks "apple" and "table" now, the remaining option for first item "apple" will be "chair". And so on...
I cannot think of an SQL to run this query that grabs elements from tbl2. I must use the selected element from tbl1 and somehow grab the REMAINING items, those that do not correspond to a mach. Is this SQL query possibe? I believe so... But cannot think of a way out...
I hope I was clear. Thanks for any help.