I have the following sql:
SELECT DISTINCT cp_pessoa.id, cp_pessoa.nome
FROM cp_pessoa
LEFT JOIN cp_habilidade_freelancer ON (cp_habilidade_freelancer.id_freelancer = cp_pessoa.id)
LEFT JOIN cp_habilidade ON (cp_habilidade.id = cp_habilidade_freelancer.id_habilidade)
WHERE cp_habilidade.id = 71 OR cp_habilidade.id = 695
LIMIT 0, 10
I want only people (cp_people) who have all the skills (71, 695).
It may seem simple, but I'm having trouble.
Examples:
If I use OR the following people with the following skills (1,2,71) are returned (people without the 695 skill). If I use AND the following people with the following abilities (71, 695) are not returned
example: sqlfiddle