Table Cars:
carID, cartitle, carmodle
Example:
1, John Car, BMW
2, Ann Car, Chery
Table Cars Options:
carID, OptionID
Example:
1,2
1,4
1,9
1,13
2,2
2,14
i need a select statement where it display the cars with options (2,13) together for example, IN wont work!
SELECT carID, count(*) as hits FROM cars JOIN options USING(carID) WHERE OptionID in (2,13) GROUP BY cars HAVING hits = 2;
SELECT node.nid, node.title
FROM node Inner Join content_type_cars ON node.nid = content_type_cars.nid Inner Join content_field_car_options ON node.nid = content_field_car_options.nid
WHERE
`content_type_cars`.`field_type_value` = '1' AND
`content_field_car_options`.`field_car_options_value` = (1, 9) AND
`node`.`type` = 'cars'
GROUP BY node.nid
ORDER BY node.created