Navigating through multiple many-to-many relationships in a single query?
Hi all! I've been racking my brain unsuccessfuly on how to accomplish my desired behavior with a query using drizzle. I don't even know how to do it in SQL honestly, and I've searched everywhere on the internet but nothing seems to do exactly what I want.
This is a stripped version of my schema just showing the relations, as the rest is pretty simple to deduce. The hierarchy is primarily meal combinations -> many food items -> many traitsWhich is a lot of many to many relationships that I want to navigate in a single query. My goal is pretty much this: "SELECT * FROM mealCombinations WHERE every linked trait from every linked foodItem is in some given list of traits." And every row that does not satisfy that condition is no longer considered.
1 Reply
The main problem I'm having is that no matter what table I query, I can't do a
where
filter specific enough to what I want it to do. Doing with
is the only way I can navigate these many-to-many relationships but it is not at all the same behavior, so I'm a bit stuck. Any help would be very very appreciated 🙏