I need to select which employees are allocated to which projects

Asked

Viewed 53 times

1

I need to select which employees are allocated to 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 really allocated. How can I refine this search?

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

alocacao

staff

funcionario

and project

projeto

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

  • 1

    Without the structures of the tables it is impossible to suggest any query.

  • 3

    Good afternoon rafael, first welcome to the community, recommend you do the tour and take a look at the section How to create a Minimum, Complete and Verifiable example

  • Rafael, have you solved your problem? what do you want to choose in a combo, what would this combo look like? Will the combo have the name of the project? , employee name? or time , used? , or what you want in reality, is a select showing the employee name + project + time?

2 answers

1

Solution is more or less like this:

SELECT projeto.nome, func.nome FROM tbProjeto as projeto
LEFT JOIN funcionario as func ON func.codFunc = projeto.codFunc
  • More or less why as the guys quoted above you didn’t pass the structures of your tables.

1

These are two correct tables ? 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.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.