I have a table posts like that:
and another table post_filters in witch I have stored the filter for each post:
where:
I want all the apples with
colorredorYellowand- from the
countryEnglandandFrance.
How can I do that with join between posts and posts_filters? It is possible to do only one join between the two tables ?
I've tried something like that:
SELECT
posts.*,
a1.*,
a2.*
FROM posts
LEFT JOIN post_filters a1 ON posts.ID=a1.post_id AND a1.filter_id=1
LEFT JOIN post_filters a2 ON posts.ID=a2.post_id AND a2.filter_id=2
WHERE
a1.selected_filter_item IN (2,3)
AND
a2.selected_filter_item IN (1,3)
It doesn't work proprierly and I would like to have only ONE join.
Aucun commentaire:
Enregistrer un commentaire