I have three tables:
Houses Table
id title description -------------------------- 1 Big House Very big house 2 Small House Very small house Rooms Table
id title room_status -------------------------- 1 Green room 24 2 Yellow room 25 3 Blue room 24 Houses_Rooms Table
id house_id room_id ------------------------- 1 1 1 2 2 3 3 1 2 I have room status 24, for example.
I need get all houses from Houses Table that contains rooms with room_status = 24. But, if house has rooms with different room_status we do not need to choose this house.
I build some query and i use WHERE house.id IN (SELECT ...). It works, but returns houses with same room_status, because IN.