Ver Mensaje Individual
  #4  
Antiguo 30-05-2018
bucanero bucanero is offline
Miembro
 
Registrado: nov 2013
Ubicación: Almería, España
Posts: 208
Reputación: 11
bucanero Va camino a la fama
con esta consulta obtienes los registros de la tabla1 que no están o no coinciden con los de la tabla2:
Código SQL [-]
select tabla1.*
from tabla1
left join tabla2 on tabla2.municipio = tabla1.municipio and tabla2.partido = tabla1.partido
where tabla2.partido is null

Y aquí una variante donde hace la unión de las dos tablas y buscas los registros que no están en ambas tablas

Código SQL [-]
select *
from (
 select *
 from tabla1
 union 
 select *
 from tabla2
 group by municipio, partido
) dat 
left join tabla1 on tabla1.municipio = dat.municipio and tabla1.partido = dat.partido
left join tabla2 on tabla2.municipio = dat.municipio and tabla2.partido = dat.partido
where tabla1.partido is null or tabla2.partido is null
Responder Con Cita