How to filter an aggregate based on a for each

Hi,


So let's say I have a table called "Favorites" and the table has the User_Id and the TeamId as Attributes.


So the table will have data like

UserId | TeamId

2         |  4

2         |  5

2         |  8

3         |  2

3         |  5


Now let's say I have a table called "Feed" and has the attribute TeamId on it

Now here's what I need, I need to filter the table feed so that if it contains any of the the TeamId associated with the user it shows those results.

I can't simpy use the filter Feed.TeamId = Favorites.TeamId and Filter.UserId = Favorites.User_Id, since the same user can have more than one team associated.

How can I achieve this?



Hopefully I was able to explain the situation well enough,

Cheers!


Hi! 

Your solution seams good. Whats the problem ? 

regards 

Graça

Maria da Graça Peixoto wrote:

Hi! 

Your solution seams good. Whats the problem ? 

regards 

Graça

Hey Graça,

So let's say the user with the id 4 has 9 rows in the table "Favorites"

So he has team 1,2,3,4,5,6,7,8 and 9 associated as favorites, each one of those is a row in the table.

If I use the filter like Feed.TeamId = Favorites.TeamId, the "Favorites.TeamId" part will only grab one of the TeamIds, if I have 9 I want it to check if there's any of those 9 in there and not just the first one.


Have you tried 

with the filter 

Favorits.UserId = UserId

For each Favorits  you'll have a record from Team. 

Hope this help 

Graça