Nested Where Clause in Many-to-Many relation using Query

Hello, I have a many-to-many relationship between my events categories table.' As of now, I am trying to filter this data by joining my events table with the junction table (eventToCategories) and then the junction table with categories table. When attempting to use the where clause in the categories table so I could filter by certain events, typescript told me that the where clause was not allowed to be used here. I am not fully sure why this is the case, but I was wondering if anyone had a solution to this? I will attach my query as well as schema things in this. Thank you.
Screenshot_2024-05-30_at_03.43.53.png
Screenshot_2024-05-30_at_04.01.50.png
Screenshot_2024-05-30_at_04.02.24.png
Screenshot_2024-05-30_at_04.03.28.png
Was this page helpful?