OQL query to search in database based on Two entities

Hi Good day. I have a domain model with two entities class instance and attribute instance connected by 1-* association (one class instance will have multiple Attribute Instance) Example: Class Instance For each class Instance Attribute Instance (3 each) as follows:   I have a UI as below: What I need is a OQL query to fetch the Class Instance that matches all the given input in above field. Please help me
1 answers

Using an absolute database with this type of database entities will indeed give you this kind of headache problems. i strongly advise against it, but you probably have no choice. So here we go:

Select * from Class
JOIN Attribute as TD
JOIN Attribute as TS
JOIN Attribute as TP
WHERE TD.Shortname = "Thread Description" and TD.AttributeValue = "the given description value"
WHERE TS.Shortname = "Thread Size" and TS.AttributeValue = "the given size value"
WHERE TP.Shortname = "Thread Pitch" and TP.AttributeValue = "the given pitch value"

Since this uses JOIN, this will result in Class only getting added to the result if TD has a value. Same for TS, same for TP. 

Still some $ and “ and names will need tweaking, but you get the drift I guess,