I have the SQL command that does not work:
SELECT
GAT_requisicao.id_GATrequisicao as 'ID Requisição',
GAP_atendimento.id_GAPatendimento as 'ID Atendimento',
GR_paciente.nome_GRpaciente as 'Nome Paciente',
GR_setor.nome_GRsetor as 'Setor Requisitante',
GR_setor.nome_GRsetor as 'Setor Executante'
FROM
GAT_requisicao, GAP_atendimento, GR_paciente, GR_setor
WHERE
GAT_requisicao.GAPatendimento_id = GAP_atendimento.id_GAPatendimento
AND GAP_atendimento.paciente_GAPatendimento = GR_paciente.nrcarteira_GRpaciente
AND GAT_requisicao.setorReq_GATrequisicao = GR_setor.id_GRsetor
AND GAT_requisicao.setorExec_GATrequisicao = GR_setor.id_GRsetor;
In the GAT_requisicao
table I have 2 columns:
- sectorReq_GATrequisition
- sectorExec_GATrequisition
One is saved the requesting sector and in the other the sector executing and these columns are filled with FK
of table GR_setor
, however what happens:
If I ask in select
to see setorReq
and setorExec
and connect the 2 tables, it does not return anything, I can only make 1 connection at a time, or connect setorExec
to table GR_setor
or connect setorReq
to table GR_setor
, the 2 connections to same return return comes null.