mysql - Filter on Many to Many relationship -


i have 3 tables product, filter, product_filter - many many relationship i'm trying filter products this:

select p.* product p inner join product_filter pf on pf.product_id = p.id (pf.filter_id = 1 or pf.filter_id = 2) , pf.filter_id = 3 

the problem there products have filters(1,2,3) 0 results

please :)

for given row in cross product there 1 filter_id. don't have 1 , 3 in same row in product_filter.

to effect try double join along these lines :-

select p.* product p inner join product_filter pf1 on pf1.product_id = p.id inner join product_filter pf2 on pf2.product_id = p.id (pf1.filter_id = 1 or pf1.filter_id = 2) , pf2.filter_id = 3 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -