I have a table called `employment` that contains two INT references named `employer` and `employee`. As a person can be either or both I have a single table named `personnel`.
I am trying to construct a query that displays
personnel.name as `employer` where employment.employer=personnel.id
AND
personnel.name as `employee` where employment.employee=personnel.id
so it extracts multiple details from one table with different where conditions and applying different alias values
Very very new to sql so my head is starting to spin
For example my personnel file:
id name
1 David
2 Simon
3 Michael
4 Tony
5 Paul
employment file:
Job 1, Title "housea" employer 2 employee 5 - I would be looking to return the values
[1][housea][Simon][Paul]
Job 2, Title "houseb" employer 1 employee 2 - I would be looking to return the values
[1][houseb][David][Simon]
If you understand what I am trying to do can you please help
I am trying to construct a query that displays
personnel.name as `employer` where employment.employer=personnel.id
AND
personnel.name as `employee` where employment.employee=personnel.id
so it extracts multiple details from one table with different where conditions and applying different alias values
Very very new to sql so my head is starting to spin
For example my personnel file:
id name
1 David
2 Simon
3 Michael
4 Tony
5 Paul
employment file:
Job 1, Title "housea" employer 2 employee 5 - I would be looking to return the values
[1][housea][Simon][Paul]
Job 2, Title "houseb" employer 1 employee 2 - I would be looking to return the values
[1][houseb][David][Simon]
If you understand what I am trying to do can you please help