我必须显示不在“timecard”表中的记录

mqxuamgl  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(267)

我必须显示不在“timecard”表中的记录-

tcID Primary int(11)                    
RequestID int(11)           
StaffID int(11)             
ShiftStartDate date             
ShiftEndDate date               
JobStartTime time           
JobEndTime time         
lunchTaken time         
ApprovalCode varchar(45)

查询:

SELECT *
FROM acceptedrequest ar
LEFT JOIN staff s ON s.StaffID = ar.StaffID
LEFT JOIN staffposition sp ON sp.PositionCode = s.PositionCode
WHERE
  ar.AgencyID = 0
  AND ar.RequestID = 2364
  and RepalceStatus = 0
  and ar.CancelStatus = 0
  and ar.BroadcastStatus = 0
9jyewag0

9jyewag01#

请提供更多详细信息,如:所有表信息及其关联方式。
如果我假设acceptedrequest人员不在timecard人员中,请尝试以下操作:

SELECT * FROM acceptedrequest ar
LEFT JOIN staff s ON s.StaffID = ar.StaffID  
LEFT JOIN staffposition sp ON sp.PositionCode = s.PositionCode 
WHERE ar.AgencyID = 0 
  AND ar.RequestID = 2364 
  AND RepalceStatus = 0 
  AND ar.CancelStatus = 0 
  AND ar.BroadcastStatus = 0  
  AND ar.staffID not in(SELECT staffID from timecard)

希望有帮助!!!

相关问题