我目前有一个select语句,它将检索员工可以获得的子邮箱表中的所有子邮箱,如果他们拥有子邮件的认证。我只需要让select语句只返回不与员工当前所有班次冲突的子文件。
子滑坡是两名雇员之间轮班交换的合同。我试图让我的网络应用程序显示员工可以采取的所有子单据。如果他们点击子转移上的转移,则Web应用程序将从旧员工转移并将其转移到新员工。
我目前的选择声明是......
SELECT S.CreatorID, S.ShiftID, S.subslipID, S.ShiftDate, S.startTime, S.endTime, S.Position, S.Reason, S.CreatedDateAndTime, E.Firstname, E.Lastname, E.Instructor, E.Lifeguard, E.Headguard, E.Supervisor
FROM `SubSlips` S
JOIN `Employees` E ON S.CreatorID = E.employeeID
WHERE `TakenTrueorFalse` = '0'
AND ShiftDate > '".$todaysDate."'
AND ( Position = 1 OR Position = 2 OR Position = 3 OR Position = 4 OR Position = 10);
如果子小贴士的日期早于今天的日期,并且子小贴士是员工认证的位置之一,则显示员工可以根据其采取与否采取的所有子小贴士。
我认为select语句需要在语句末尾附加一个“NOT IN(同时的SELECT转换”)。
NOT IN(
SELECT ShiftID FROM Shifts
WHERE `CurrentOwnerEmployeeID` = '".$EmployeeID."'
AND `date` = S.ShiftDate
AND `startTime` Between S.startTime AND S.endTime
OR `date` = S.ShiftDate
AND `endTime` Between S.startTime AND S.endTime
OR `date` = '".$date."'
AND S.startTime Between `startTime` AND `endTime`)
那么我怎样才能让我的Select Statement返回当前登录的员工当时没有班次的子单据?
编辑 这是我的select语句,其中没有添加逻辑。
SELECT S.CreatorID, S.ShiftID, S.subslipID, S.ShiftDate, S.startTime,
S.endTime, S.Position, S.Reason, S.CreatedDateAndTime, E.Firstname,
E.Lastname, E.Instructor, E.Lifeguard, E.Headguard, E.Supervisor FROM
`SubSlips` S JOIN `Employees` E ON S.CreatorID = E.employeeID WHERE
`TakenTrueorFalse` = '0' AND ShiftDate > '2017-12-31'
AND ( Position = 1 OR Position = 2 OR Position = 3 OR Position = 4 OR
Position = 10) AND
NOT IN( SELECT ShiftID FROM Shifts
WHERE `CurrentOwnerEmployeeID` = '8' AND
`date` = S.ShiftDate AND
`startTime` Between S.startTime AND S.endTime
OR `date` = S.ShiftDate AND `endTime` Between S.startTime AND S.endTime
OR `date` = S.ShiftDate AND S.startTime Between `startTime` AND `endTime`);