我有两张表SelfAnswers和Employee。在执行以下查询时:我想返回不同的结果。
SELECT s.Id,s.EmployeeId,e.NAME,e. Department
FROM SelfAnswers AS s Inner Join Employee As e ON s.EmployeeId=e.EmployeeId
输出
Id EmployeeId NAME Department
1 100 adam Exam
2 100 adam Exam
3 100 adam Exam
4 100 adam Exam
5 101 smith Exam
6 101 smith Exam
7 101 smith Exam
8 101 smith Exam
答案 0 :(得分:1)
好吧,查询返回了不同的结果。
如果您指的是EmployeeId, NAME and Department
,那么您可以尝试类似
SELECT DISTINCT
s.EmployeeId,
e.NAME,
e. Department
FROM SelfAnswers AS s Inner Join
Employee As e ON s.EmployeeId=e.EmployeeId