MySQL Inner Join with null Id columns

0

I have a table where there are several related ids and using inner join I get the data the problem is that some records do not keep an id and I put value Null and when ago the select with inner join does not show me the data with null value

This is the selection I use:

SELECT c.idCaja,c.FechaIngreso,td.nDoc,c.numDoc,d.nDescripcion,cen.nCentroCosto,c.egreso,c.tot_egresos,tp.nTipPago,c.mov_efectivo,c.saldo_efectivo,c.mov_banco,c.saldo_banco FROM caja_chica c join tipodoc td on c.idDoc=td.idDoc join descripcion d on c.idDescripcion=d.idDescripcion join centro_costo cen on  c.idCentroCoto=cen.idCentroCosto join tipopago tp on c.idTipPago=tp.idTipPago

Here is a capture of the table and the record:

Can someone help me solve this problem?

    
asked by Luis 09.10.2018 в 19:49
source

1 answer

2

You have to change the inner join for left join.

SELECT c.idCaja,c.FechaIngreso,td.nDoc,c.numDoc,d.nDescripcion,cen.nCentroCosto,c.egreso,c.tot_egresos,tp.nTipPago,c.mov_efectivo,c.saldo_efectivo,c.mov_banco,c.saldo_banco 
FROM caja_chica c 
left join tipodoc td on c.idDoc=td.idDoc 
join descripcion d on c.idDescripcion=d.idDescripcion 
join centro_costo cen on  c.idCentroCoto=cen.idCentroCosto 
join tipopago tp on c.idTipPago=tp.idTipPago
    
answered by 09.10.2018 / 19:56
source