我有一個表,看起來像這樣MySql的排除查詢
JOB_ID | Email | Type | Date
_____________________________________
28319 | [email protected] | Service | 11-24-2016
_____________________________________
28412 | [email protected] | Rotation | 11-24-2016
_____________________________________
38123 | [email protected] | Service | 11-24-2016
_____________________________________
28199 | [email protected]| Service | 11-24-2016
什麼是查詢我會跑回到那些誰安排了服務,但沒有在特定日期的旋轉。
這是我的嘗試:
SELECT j.Job_ID,j.Email,j.Type,j.Date
from Jobs j
join
Jobs j2
on j.Email = j2.Customer_Email
where j2.JOB_ID NOT IN (select j.JOB_ID
from Jobs j
where j.Type = 'Rotation'
) AND j.Date = '11-24-2016';
所以我的查詢將返回安迪和羅傑。
作爲,使用適當的數據類型 – Strawberry