Hi,
I'm looking for a push in the right direction.
Using LLBLGEN 4.1, SQL Server, QuerySpec Adapter Queries.
I have (among quite a few other) the following tables in my project. Names can be somewhat confusing as they're from another system and not defined in our project:
ProductTerm
PK Fields: VocabularyId, TermId, ProductId
Other fields: none
Vocabulary
PK fields: VocabularyId, TermId
Other field: ProductId
VocabularyLocale
PK Fields: VocabularyId, Language
Other Field: Name
Product
PK Field: ProductId
Other fields: several, but not relevant here
ProductLocale
PK Fields: ProductId, Language
Other field: Name
Now, I'm trying to write a query that gives me all Vocabulary records of products that are linked to a Term with TermId = 123 and VocabularyId = 'abc'.
In SQL I'd write something like this
SELECT Vocabulary.VocabularyId, VocabularyLocale.Name
FROM ProductTerm
INNER JOIN Vocabulary ON <keys>
WHERE ProductTerm.ProductId IN
(SELECT ProductId FROM ProductTerm WHERE TermId = 123 and VocabularyId = 'abc')
I'm sorry I didn't post real code. I could (and will if anyone wants), but I'm afraid it would make things way more complicated (for example, I also need to look for search words in the ProductLocale and TermLocale tables, for example table. And it's the concept of this WHERE ... IN (SELECT ... ) that I'm after.
In a more common Customers/Orders/Products scenario, I think a question like this would be pretty much the same:
Give me al Orders of Customers that have Product X on at least one of their Orders.
I could really use a push in the right direction as to write a query like this.
Thanks!
Stefan