I have 2 table called Classifieds
and Classifieds_meta
below is the screenshot of classifieds_meta table
im writing a search filter function with muliple where clause like
SELECT *,classifieds.id as id
FROM classifieds,classifieds_meta
WHERE (category=2 OR category=3 OR category=4 OR category=5)
AND ((meta_key='vehicle_make' and meta_value=3 OR meta_key='vehicle_make' and meta_value=4)
AND meta_key='vehicle_mileage' and meta_value=9 OR meta_key='vehicle_mileage' and meta_value=10 OR meta_key='vehicle_mileage' and meta_value=11 )
AND classifieds.id=classifieds_meta.classifieds_id
GROUP BY classifieds.id
But the above sql statement IGNORES vehicle_make
, meta_value
and meta_key
field condition, and displays incorrect result, what i want to achieve exactly is i want to get vehicles where category is in (2,3,4 or 5) and meta_key is vehicle_make and meta_value is 3 or 4 and meta_key is vehicle_mileage and meta_value is 9,10 or 11.
can someone please help me to form better SQL statement to get right result