Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SQL查询联接4个表_Sql_Sql Server - Fatal编程技术网

SQL查询联接4个表

SQL查询联接4个表,sql,sql-server,Sql,Sql Server,我是SQL新手,我想编写查询以获取报告 员工(EmployeeID,EmployeeName) 作业(EmployeeID(外键),JobEndDate(可空)) 文件(文件ID,文件名) EmployeeFilling(EmployeeID(外键)、FileID(外键)、ReceivingDate(可空)、ExpiryDate(可空)、ReturnedDate(可空)、DeliveryDate(可空)) 我想要的是: Sellect Filles where DeliveryDate Is

我是SQL新手,我想编写查询以获取报告

  • 员工(EmployeeID,EmployeeName)
  • 作业(EmployeeID(外键),JobEndDate(可空))
  • 文件(文件ID,文件名)
  • EmployeeFilling(EmployeeID(外键)、FileID(外键)、ReceivingDate(可空)、ExpiryDate(可空)、ReturnedDate(可空)、DeliveryDate(可空))
我想要的是:

Sellect Filles where DeliveryDate Is Null & JobEndDate Is Not Null For All Employees
比如:

SELECT F.FileName FROM FILES F 
JOIN EMPLOYEEFILING EMPF ON F.FILEID = EMPF.FILEID 
JOIN JOB J ON J.EMPLOYEEID = EMP.EMPLOYEEID 
WHERE EMPF.DELIVERYDATE IS NULL AND J.JOBENDDATE IS NOT NULL


基本上,您可以对SQL连接以及在哪种情况下可以使用它进行更多的研究

请尝试下面的问题查询

SELECT employee.EmployeeID,employee.EmployeeName, Job.JobEndDate, Files.FileName,EmployeeFilling.DeliveryDate
FROM Employee e,Job j, Files f,EmployeeFilling ef
where e.EmployeeID =j.EmployeeID and e.EmployeeID = ef.EmployeeID and f.FileID=ef.FileID
and ef.DeliveryDate is null and JobEndDate is not null;

伟大的。感谢分享您的需求。你试过什么?你听说过吗?样本数据和期望的结果会很有帮助。“面向所有员工”的支持意味着什么?