我的数据库中有三个表
员工表
- 员工 ID (PK)
- 姓
问题表
- 启德(PK)
- 问题
问卷
- QuestionnaireId (PK)
- QId (FK)
- 员工 ID (FK)
- 回复
- 细节
这是我自己编写的 SQL 查询,但它产生了我不需要的输出
Select q.qid,e.employeeId, q.Question, eq.response
from employee e
cross join Question q
left outer join employeequestionnaire eq on q.Qid= eq.Qid
where e.employeeId = 1
这是输出
Qid EmployeeId Question Response
"1" "1" "Question1" "0"
"1" "1" "Question1" "1"
"2" "1" "Question2" "1"
"2" "1" "Question2" "0"
"3" "1" "Question3" "1"
"4" "1" "Question4" NULL
但我需要这种输出
Qid EmployeeId Question Response
"1" "1" "Question1" "0"
"2" "1" "Question2" "1"
"3" "1" "Question3" "1"
"4" "1" "Question4" NULL
我是 SQL 的新手,对不起我的示例查询..