I need to select which officials are allocated on which projects

1

I need to make a select of which officials are allocated on which projects but when I run my code:

select projeto.nome, funcionario.nome from projeto, funcionario

It selects all names in all projects and not how they are actually allocated. How can I refine this search?

edit: are organized as follows in 3 tables: allocation.

official

andproject

If something is missing please ask, I started mysql recently.

    
asked by anonymous 08.11.2018 / 18:57

2 answers

1

Solution looks something like this:

SELECT projeto.nome, func.nome FROM tbProjeto as projeto
LEFT JOIN funcionario as func ON func.codFunc = projeto.codFunc
    
08.11.2018 / 19:00
1

Is it two tables correct? In this case try the following:

select projeto.nome, funcionario.nome from projeto
join funcionario
    on funcionario.id = projeto.funcionario

Check the relationships between tables as this is just an example.

    
08.11.2018 / 19:01