4
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 only want people (cp_person) who have all the skills (71, 695).
It may seem simple, but I’m struggling.
Examples:
If I use OR the following persons with the following abilities (1,2,71) are returned (persons without the 695 skill). If I use AND the following persons with the following abilities (71, 695) are not returned
example: sqlfiddle
works, and doesn’t need to use Joins (which is +1 for me)
– woliveirajr