Ver Mensaje Individual
  #7 (permalink)  
Antiguo 06/01/2015, 10:52
felipe12357
 
Fecha de Ingreso: junio-2010
Mensajes: 168
Antigüedad: 13 años, 10 meses
Puntos: 3
Respuesta: join con una vista no muestra los campos null

hola, al ejecutar:
Código MySQL:
Ver original
  1. select DISTINCT e.nit,f.total total,e.entidad
  2. from entidades e
  3. LEFT JOIN vw_rojof f
  4. on e.nit=f.nit

da como resultado:
Código HTML:
Ver original
  1. 89090924xx  1   BELEN
  2. 8909814xx   1   CREAR
  3. 8909048xx   1   TELEP LTDA.
  4. 8600134xx   1   FONDO ASOCIACIÓN
  5. 8600148xx   1   FONDO IPSE
  6. 8002107xx   1   FONDO COL

y cuando ejecuto:
Código MySQL:
Ver original
  1. select DISTINCT e.nit,f.total total,e.entidad
  2. from entidades e
  3. (
  4. SELECT nit,1 as total
  5.  FROM entidades
  6.  where nit not in (select DISTINCT nit from cotizaciones)
  7.             and nit not in (select DISTINCT nit from convenios)
  8. and nit!='' and nit!=0) as f
  9. on e.nit=f.nit

da como resultado: (este es el q se debería obtener)

Código:
89090924xx		BELEN 
8909814xx		CREAR
8909048xx		TELEP LTDA.
8600134xx		FONDO ASOCIACIÓN
8600148xx	1	FONDO IPSE
8002107xx	1	FONDO COL
al ejecutar tanto la vista vw_rojo como la subconsulta mencionada (por separado) obtengo la misma cantidad de datos 1152