M
M
Msim2015-06-20 20:48:14
PHP
Msim, 2015-06-20 20:48:14

How to organize a search for similar products?

There is a product and a product category is available
Weight 0.4 kg
Volume 400 ml
Type Anti-dandruff
Filler Citrus
Trademark Head&Shoulders
It is necessary to organize a search for similar products:
I implemented it like this "Weight" is a separate element of the database "0.4 kg" is a separate , the category is a separate id

select DISTINCT pro.id_product , pro.id_feature_value from ps_feature_product as pro 
JOIN ps_category_product as cat on pro.id_product = cat.id_product
WHERE pro.id_feature_value = 25663 and cat.id_category = 800

but if you do
select DISTINCT pro.id_product , pro.id_feature_value from ps_feature_product as pro 
JOIN ps_category_product as cat on pro.id_product = cat.id_product
WHERE pro.id_feature_value = 9865 and cat.id_category = 800 and pro.id_feature_value = 9855

Outputs nothing, although 2 products have this property at the same time. I suspect that these are subtleties of sql syntax, can anyone tell me how to pull out a product with 2-3-4 identical properties?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2015-06-21
@yarosroman

WHERE pro.id_feature_value = 9865 and cat.id_category = 800 and pro.id_feature_value = 9855
how can pro.id_feature_value be 9865 and 9855 at the same time? means to replace and with or, like so
WHERE cat.id_category = 800 and (pro.id_feature_value = 9865 or pro.id_feature_value = 9855)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question