Answer the question
In order to leave comments, you need to log in
2 tables: Products, Parameters. How to make a request?
there are 2 tables:
product:
id
params:
id
id_product
params (there can be: color, price, size, etc.)
value (values for each parameter)
How to make a query, if you need, for example, find - id_product with colors blue, green , price from 50 to 100 and sizes from 39 to 41
------------------------------------- -------------------------------------------------- ----------------------------------
And the second version of the tables (what is the best way to organize the tables, according to the first or second options? ):
product:
id
price
params:
id
id_product
params (there can be: color, size, etc.)
value (values for each parameter)
Answer the question
In order to leave comments, you need to log in
Read about the entity-attribute-value of the table
If your price for a product does not change depending on the color, size or any other parameter, then the price is stored in the products table.
products_params structure:
product_id | param | value
1 | color | green
1 | color | blue
2 | color | green
3 | color | blue
1 | weight | 300
select * from products_params where product_id = 1 and param = 'color'
Isn't it easier if you make 1 table, where at once, for each product, there will be parameters?
id | color | price | size | weight | other_info
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question