I have 3 tables which i want to join and i just need the data for 1 staff in 1 row but i get multiple or more to say multiplied rows.
staff:
uid | surname |
---|---|
1234 | Miller |
4567 | Jake |
position:
uid | role | from | to |
---|---|---|---|
1234 | Engineer | jan | dec |
1234 | Worker | jan | dec |
knowledge:
uid | certificate | from | to |
---|---|---|---|
1234 | cert1 | jan | dec |
1234 | cert2 | jan | feb |
position content has no relation/dependency to knowledge content.
This is what i get with my sql query, obviously without the header as i dont know to do this but just here for understanding with header. I get 4 (2x2) lines but as mentioned before i don't need this as data is completely unrelated from the two tables position and knowledge
uid | surname | role | from | to | certificate | from | to |
---|---|---|---|---|---|---|---|
1234 | Miller | Engineer | jan | dec | cert1 | jan | dec |
1234 | Miller | Engineer | jan | dec | cert2 | jan | feb |
1234 | Miller | Worker | jan | dec | cert1 | jan | dec |
1234 | Miller | Worker | jan | de | cert2 | jan | feb |
This what i tried:
Select st.uid, st.surname, pos.role, pos.from, pos.to, knw.certificate, knw.from, knw.to
from staff st
join position pos on st.uid=pos=uid
join knowledge knw on st.uid=knw.uid
WHERE st.uid='1234'
What i'm trying to get:
uid | surname | role | from | to | role | from | to | certificate | from | to | certificate | from | to |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1234 | Miller | Engineer | jan | dec | Worker | jan | dec | cert1 | jan | dec | cert2 | jan | feb |
Roles and also certificates can be none or even more and should be lined up in one row. I used google to find solutions to show in one row but just got the typical "just show 1 row of table" (TOP) as search results. I don't need the header and would be interested in a data result only to have a better understanding and not to overcomplicate stuff. Thank you.