SQLTeam.com | Weblogs | Forums

Problem with duplicate when join tables

Hi All.
When I join this two tables

tables

SELECT
Name,
Description,
EmployeeDeptId,
FROM EmployeeDept ed
JOIN Department d
ON ed.DepartmentId = d.DepartmentId

as in result I'm getting duplicates for Name. How to join tables and eliminate duplicates?
Thanks.

The employee belongs to more than 1 department. Pictures are nice, but DDL and sample data would be better. I see IsActive, should that be used? If an employee is assigned to more than one department, which it sounds like your data has, then you will get multiple rows.

Or there are many employees in same department and since you have no filter there will be duplicate department Name

What is the row count of this query

select [name] from department

and what is the row count of this query

select distinct [name] from department

I dont think that makes a difference, look at the query. If you and I are in same department of course there will be 2 of the same department right?

Yes, several people can belong to same department.

Since he did't provide his duplicate result set,
I thought second possibility of asking his question.