Hello! I have a table, it stores data on dynastic fields. It looks like this:
id | product_id | category_id | field_id | value_string | value_int 1 | 15 | 120 | 1 | Brand 1 | 0 1 | 16 | 120 | 1 | Brand 2 | 0 1 | 15 | 120 | 2 | null | five 1 | 16 | 120 | 2 | null | 15 1 | 17 | 120 | 1 | Brand 1 | 0 1 | 17 | 120 | 2 | null | 55
field_id with id 1 - brand field, with id 2 - size
I need to get a product_id whose field brand (field_id - 1) is "Brand 1" and "Brand 2" and field size (field_id - 2) with a range for example from 5 to 40
From the data above, the result should be product_id from 15 and 16. product_id from 17 does not match the range, although the brand field contains “Brand-1”
Tell me which way to go. I would like an example implementation on Yii2, but I will be grateful for a clean sql example.
PS
Maybe I did not build a table with data, if so, tell me what is wrong and how best.
Thank! All good!