I have an SQL statement that has multiple joins. I would like to us the IN statement for both tables, like so:
SELECT
p.id, p.first_name as [First Name],
p.last_name as [Last Name]
FROM
tbl_person as p ,
tbl_person_languages as pl ,
tbl_person_skills As ccp
WHERE
pl.language_id in (12,14) AND
ccp.skill_id in (55)
GROUP BY
p.id, p.first_name , p.last_name
HAVING
count(pl.language_id) = 2 and count(ccp.skill_id) =1
So, I would like to pull back all, distinct, records where a person has language_ids equal to 12 AND 14 and have skill_id = 1. But, this returns an empty set. I have confirmed that the data exists for at least one record, so I should see something.
I should note, there will be more joins and the language_ids and skill_ids values can change. This is similar to a previous question I asked (Access SQL using IN where record must satisfy all values) but this is with multiple joined tables. thanks
EDIT
I have updated the SQL to use Joins, as such:
SELECT
p.id,
p.first_name as [First Name],
p.last_name as [Last Name]
FROM
(( tbl_person as p
INNER JOIN tbl_person_languages as pl
ON p.id = pl.person_id)
INNER JOIN tbl_person_crossCuttingSkills As ccp
ON p.id = ccp.person_id)
WHERE
pl.language_id in (12,14) AND
ccp.skill_id in (55)
GROUP BY
p.id,
p.first_name,
p.last_name
HAVING
count(pl.language_id) = 2 AND
count(ccp.skill_id) =1
But this now creates a syntax error (missing operator).