I am not an expert in SQL and I have the following problem ... I have two "related" tables, one of products and another of product characteristics in which I keep values that these products can have, for example: colors, materials , sizes, etc ...
What I am doing is a filter that pulls out products according to the selected characteristics but I have the problem when it comes to extracting the results with the following sentence:
SELECT
productos.ref,productos.nombre,caracteristicas.ref,caracteristicas.idvalor
FROM productos
LEFT JOIN
caracteristicas ON (caracteristicas.ref=productos.ref)
WHERE
(caracteristicas.idvalor = 384 OR caracteristicas.idvalor = 379 ) and
(caracteristicas.idvalor = 377)
ORDER BY
productos.nombre ASC
Before I had it all with a IN
style ... caracteristicas.idvalor IN (384,379,377)
what I do not want to remove the products that have those characteristics, but the query is ...
Products that have 384 or 379 and also have 377.
I do not know if I explain myself?
The query does not give an error, but it does not give me results when there are records that meet those conditions.
Any help?
Thanks in advance.