Trying to get a list of employees who have a particular set of certificates, e.g. BSCS and MSCS certificates.
Certificates Table
Employee Certificates
SELECT * FROM users AS u
JOIN employee_certificates e ON e.user_id = u.id
JOIN certificates c ON e.certificate_id = c.id
WHERE c.id = 9 AND c.id=10
Return Nothing But when I use
WHERE c.id IN (9,10)
Returning employees 206,207,208
Because they have these Certificates.
But what I want are the employees that have both BSCS and MSCS certificates.
Using this Query I can get result with Certificate id 9 and 10.. but how can i join user to get user detail.
Select certificate_id
from
(
Select distinct user_id, certificate_id
from
employee_certificates
where certificate_id in (9,10)
) a
group by certificate_id
i try this query but getting delicate result
Select certificate_id,a.name
from
(
Select distinct user_id, certificate_id,u.name
from
employee_certificates
JOIN users u ON u.id = employee_certificates.user_id
where certificate_id in (9,10)
) a
group by certificate_id,a.name
What is Right Result i'm excepting? return only 1 user who's user_id is 206 has both certificate (9,10)