SQL statement error

2

I have the following DB:

WhenIrunthefollowingQuery:

SELECTtbCelula.*FROM(((tbTiposMonitorizacaoINNERJOINtbMonitorizacaoProjONtbTiposMonitorizacao.TM_ID=tbMonitorizacaoProj.MP_T_ID)INNERJOINtbListaConformidadesONtbMonitorizacaoProj.MP_ID=tbListaConformidades.L_MP_ID)INNERJOINtbCelulaONtbTiposMonitorizacao.TM_ID=tbCelula.C_TM_ID)INNERJOINtbValoresON(tbListaConformidades.L_ID=tbValores.V_L_ID)AND(tbCelula.C_ID=tbValores.V_C_ID)WHERE(((tbListaConformidades.L_ID)=21));

ThestatementdoesnotreturnallofthedataIwanttoquery.

Output:

Expectedresult:

    
asked by anonymous 11.12.2015 / 11:28

1 answer

0

Probably when you run this

INNER JOIN  tbValores ON (tbListaConformidades.L_ID = tbValores.V_L_ID)

Your select will only bring the records where tbListaConformidades.L_ID = tbValores.V_L_ID . Every time you do inner join, the query will only return where it has records in all tables. Do the test and add values to the records that are blank and you will see that they will appear in the query. Example 1: We have a record where tbListaConformidades.L_ID = 7 however has no record where tbValores.V_L_ID = 7 , then it will be discarded from the query and will go to the next. Example 2: We have tbListaConformidades.L_ID = 3 and TEMOS tbValores.V_L_ID = 7 , then yes it will be printed in the query return.

    
11.12.2015 / 12:35