我有一個表爲工作日分配工作日ID。簡單的MySql SELECT
Table: workdays Table: jobs
+------+-------+ +------+-----------+
| id | days | | id | jobs |
+------+-------+ +------+-----------+
| 1 | mon | | 1 | cleaning |
| 1 | tue | | 2 | cooking |
| 2 | sat | | 3 | driving |
| 3 | mon | | 4 | cleaning |
| 3 | tue | | 5 | cooking |
| 3 | sat | +------+-----------+
| 4 | wed |
| 4 | mon |
| 5 | tue |
+------+-------+
這是我用它來選擇的人誰在任何的日工作的ID我指定(比如週一和週二)查詢:
SELECT * FROM workdays WHERE days IN ('mon', 'tue')
現在,我想選擇那些在我指定的所有日子裏工作的人。我怎樣才能做到這一點?
編輯:增加第二個表。
假設(ID,日)是唯一的... GROUP BY ID HAVING COUNT(*)在(項目=數) – Strawberry
@ Zap7都能跟得上。它會返回**空**。 –
誰提高了? – Strawberry