Whats wrong with this SQL? It should return results but returns nothing
SELECT `pid`
FROM `products`
LEFT JOIN `prods_to_features`
ON (`ptf_pid` = `pid`)
WHERE ( `ptf_id` = '66'
OR `ptf_id` = '67'
)
AND (`ptf_id` = '76')
Is it not possible to have the 2nd where clause for the table that has been used in the left join?
As others have said, the WHERE clause makes no sense.
I’m going to guess that what you’re trying to say is you want products that have a feature-76 AND have a feature 66-or-67. You will need two joins for that:
The DISTINCT is to ensure only one copy of a product is returned in the case where a product has both features 66 and 67.