I have two MySQL tables: house and features. This is for a real estate website.
house has this structure:
id | address | ... some other fields
features has this structure:
id | house_id | feature | value
as you can guess, a house can have multiple features, so a 1:n relationship exists.
Now, I’m implementing a search form for houses. I need to filter the results based on the features selected by the user.
Sample scenario: get all houses which have the features garage and garden, and a list of features in those houses.
What would be the best query to suit my needs? I’m not familiar with JOIN operations, so I need your help!
(OPTIONAL) If you can provide a Yii Framework-specific solution, it would be awesome 🙂
1 Answer