I got a DB where I have 3 tables.
-
t_user
which contains users. Each User needs to specify his 3 branches. Like , Electronic, Architecture or Paintings. -
t_adverts
contains ads which can be assigned to different branches. Like above, Electronic, Architecture, Gaming, Gambling, etc. -
t_branchdepencies
contains these informations which user is assigned to which branch. And each advert can be also assigned to branches.
So note: User fits into max 3 branches. One Advert can also fit into branches.
Now my logic problem starts here. How can I select all adverts where the user matches his defined branches? Do I need to add the same branchdepencies table twice as a JOIN ? One where I match the t_user defined branches and then again and try to match the t_advert defined branches?
Smth like that? Its the same table, but used twice