I am trying to bring data that is not found in another table with codeigniter
My model:
public function getEntradas($proveedor){
//Mostrar entradas del proveedor que no estan en pagos
$this->db->select('e.id,e.cajas,e.peso,e.status,e.hora,e.fecha,h.nombre as nombre_huerta,r.nombre as nombre_proveedor');
$this->db->from('entrada e');
$this->db->distinct();
$this->db->join('pagos p','e.id != p.identrada');
$this->db->where('e.idproveedor',$proveedor);
$this->db->join('huerta h','e.idhuerta = h.id');
$this->db->join('proveedor r','e.idproveedor = r.id');
$this->db->order_by('e.id','desc');
$result = $this->db->get();
return $result->result();
}
This shows me all the information the id 246
is already in my table pagos
therefore it should not be displayed.
If this line is modified:
$this->db->join('pagos p','e.id != p.identrada');
by:
$this->db->join('pagos p','e.id = p.identrada');
It only shows me the 246
the inverse if it applies the logic but because it does not work the !=
My tables:
SQL generated code:
SELECT DISTINCT
'e'.'id', 'e'.'cajas', 'e'.'peso', 'e'.'status', 'e'.'hora', 'e'.'fecha',
'h'.'nombre' as 'nombre_huerta',
'r'.'nombre' as 'nombre_proveedor'
FROM 'entrada' 'e'
INNER JOIN 'pagos' 'p' ON 'p'.'identrada' != 'e'.'id' JOIN 'huerta' 'h' ON 'e'.'idhuerta' = 'h'.'id' JOIN 'proveedor' 'r' ON 'e'.'idproveedor' = 'r'.'id' WHERE 'e'.'idproveedor' = '79' ORDER BY 'e'.'id' DESC