so there is a table of parameters which is associated with the "offer". The parameters table looks like this:
- offer_id
- parameter_name
- parameter_value
Table entries look like this:
offer_id | parameter_name | parameter_value
1 | price | 100
1 | width | 150
1 | height | 200
1 | place | left
1 | place | right
2 | price | 300
2 | width | 150
2 | height | 200
Now I want to perform a search using MySQL query in this table, where
- price is more than 80 AND less than 120
- width is equal to 150
- height is equal to 200
- place is either left OR right
The expected outcome:
- offer_id = 1
How would a MySQL query look like?
Thanks a lot.
Something like this:-
Note that this will bring back multiple rows sometimes (ie id of 1 would come back more than once). You can remove this with a DISTINCT if you want. Depends how the data is to be used.