0
Please help me check my query because it is giving an error that I am not able to identify. If I do the simple consultation:
SELECT
*
FROM
respostas
WHERE
resp_usuario='8'
AND resp_questionario='6'
Returns results normally,more if I enter a Join does not return anything,follow the Join query:
SELECT
q.quest_nome AS QUESTIONARIO,
u.usu_id AS ID_USUARIO,
u.usu_nome AS USUARIO,
l.loja_id AS END,
a.area_desc AS SETOR,
sb.sub_area_nome AS SUBAREA,
p.perg_desc AS PERGUNTA,
r.resp_resposta AS RESPOSTA,
p.perg_peso AS PESO,
(p.perg_peso * r.resp_resposta) AS PONDERADA,
(p.perg_peso * 5) AS MAXIMO,
(p.perg_peso * r.resp_resposta / (p.perg_peso * 5)*100)PERCENTUAL
FROM
respostas AS r
INNER JOIN questionario AS q ON r.resp_questionario = q.quest_id
INNER JOIN usuarios AS u ON r.resp_usuario = u.usu_id
INNER JOIN lojas AS l ON r.resp_loja = l.loja_id
INNER JOIN area AS a ON r.resp_area = a.area_id
INNER JOIN sub_area AS sb ON r.resp_subgrupo = sb.sub_area_cod
INNER JOIN perguntas AS p ON r.resp_pergunta_id = p.perg_id
WHERE
r.resp_usuario='8'
AND r.resp_questionario='6'
What I could be doing wrong ?
Att,
Most likely, no record meets the conditions. Tip can go removing the Join one by one and find out which 'fault' query piece or exchange it for left Join just for testing.
– rray
Great, I managed to identify by the left Join. Thank you very much, please put as an answer so I can score for you. Hugging.
– Chefe Druida