I have one table for workers and an other for offices. One worker can be in different offices or in any.
The tables are like:
**Workers**
ID | Name
1 | Ned
2 | James
3 | Tyrion
**WorkersOffices**
WorkerID | OfficeID
1 | 18
1 | 17
2 | 18
I want to join the two tables to get something like this:
**Joined**
ID | Name | OfficeID
1 | Ned | 18
1 | Ned | 17
2 | James | 18
3 | Tyrion |
I have tried the following but it only join one office for worker.
SELECT * FROM workers w
LEFT JOIN workersoffice wo on w.id = wo.workerid
How can I obtain this result?