These are two tables 1. emp_table, 2. phone_table. How to get employee name and id who have two phone numbers in second table
Asked
Active
Viewed 666 times
1 Answers
0
SELECT t1.id,
t1.name
FROM emp_table t1
INNER JOIN -- the join will remove employees who do not have
( -- two phone numbers in phone_table
SELECT Id
FROM phone_table -- this query identifies all employees
GROUP BY Id -- having two phone numbers in phone_table
HAVING COUNT(*) = 2
) t2
ON t1.id = t2.Id

Tim Biegeleisen
- 502,043
- 27
- 286
- 360