SELECT with multiple tables returns only one project

-2

I'm doing a project management system, in the HOME page will appear all projects. In mySQL I have in the PROJECTS table the client and project manager saved as User ID and Client ... that has their data in other tables CLIENTS and USERS. I'm doing a SELECT in PHP in mySQL that should return all projects to me, but returns only one.

$sql = "SELECT projects.id P_ID, projects.gerente P_GERENTE, projects.cliente P_CLIENTE, projects.nome P_NOME, projects.area P_AREA, projects.data_final_plan P_DATA, users.nome U_NOME, users.sobrenome U_SOBRENOME, clients.nome C_NOME FROM projects INNER JOIN users ON projects.gerente = users.id INNER JOIN clients ON projects.cliente = clients.id";

Does anyone know why? I think by projects.gerent = users.id and projects.client = clients.id ...

I think because this ID = 1 CLIENT = 2 MANAGER = 1 does not appear and ID = 1 CLIENT = 1 MANAGER = 1 and this one appears !!! I need to make SELECT return without comparing if the manager ID is equal to the client ID!

    
asked by anonymous 25.05.2018 / 20:13

1 answer

0

Attempt to exchange INNER for LEFT

Ex:

$sql = "SELECT projects.id P_ID, 
           projects.gerente P_GERENTE, 
           projects.cliente P_CLIENTE, 
           projects.nome P_NOME,
           projects.area P_AREA, 
           projects.data_final_plan P_DATA, 
           users.nome U_NOME, 
           users.sobrenome U_SOBRENOME, 
           clients.nome C_NOME
      FROM projects 
      LEFT JOIN users   ON projects.gerente = users.id 
      LEFT JOIN clients ON projects.cliente = clients.id";
    
25.05.2018 / 20:22