Skip to content
Advertisement

Select common Interactions mysql [closed]

I have this 3 tables:

what I want is select which level can interact with the room.

  • If I check for room 1, the answer should be level 1 and 2 (because John is level 1 and he is only able to interact with level 2) even though Josh as level 2 can interact with level 3.

  • If I check for room 3, because only Josh is there, the answer should be 1 2 and 3.

  • If I select the room 2, the answer should be level 2 and 3.

Basically what I want is a way to select common interaction level for members on the room!

Check the table/dataset on: https://paiza.io/projects/NKkAQUg9CuB_46rXZdEVEA?language=mysql

Advertisement

Answer

Join the tables and group by li.interact_with with a condition in the HAVING clause:

See the demo.
Results (for room_id = 1):

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement