I am trying to get parts which have certain attributes. Each part
has many attributes, and each attribute
has an attributeheader
. So there's three tables that I need to use.
SELECT * FROM Part p
LEFT JOIN p.attributes pa
JOIN pa.attributeheader pah
WHERE (sph.name = 'size' AND sp.value IN ('11'))
AND (sph.name = 'colour' AND sp.value IN ('Black'))
This returns nothing as I've gone wrong somewhere on the JOIN, or the lack of grouping. I'm trying to select the parts which have both attributes, so using OR
is not a solution. I can't quite work out how to go about this - using raw MySQL I would use aliases on the join.