R
R
Rasul Kakushev2018-08-31 09:53:53
MySQL
Rasul Kakushev, 2018-08-31 09:53:53

How to make the right choice?

There are 3 tables products and properties and property_values
​​The products table has id, title, price
fields The properties table has id, title fields The property_values ​​table has id, product_id
, property_id, value fields
values, that is something like this

select * from products left join property_values on products.id = property_values.product_id where property_values.property_id = property_id_1 AND property_values.value = value_1 AND  property_values.property_id = property_id_2 AND property_values.value = value_2

How to organize such a request?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Telepnev, 2018-08-31
@TelepnevDmitriy

SELECT product.*, properties.title, values.value
FROM products
JOIN property_values values ON values.product_id = product.id
JOIN properties ON properties.id = values.property_id
WHERE values.property_id IN (......)

or
WHERE (values.property_id, values.value) IN ( (1,2), (2,12) )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question