Ver Mensaje Individual
  #4 (permalink)  
Antiguo 10/03/2009, 02:31
jurena
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Cáceres
Mensajes: 3.735
Antigüedad: 16 años, 1 mes
Puntos: 300
Respuesta: actualizar y agregar de u na tabla a otra

Antes deberías aclararnos que es rif, si un identificador, numérico y autoincrement que coincide en ambas tablas o qué.
Mira esto: te permite añadir los que no están en otra tabla, pero yo no he tenido en cuenta ese rif, que si no es un autoincrement podrás añadir en la inserción
A) sin rif
insert into clientes (cliente, direccion, vendedor, creacion) select tc.cliente, tc.direccion, tc.vendedor, tc.creacion from tmp_clientes tc where tc.cliente not in (select c2.cliente from clientes c2)

B) con rif no auto_increment
insert into clientes (rif, cliente, direccion, vendedor, creacion) select tc.rif, tc.cliente, tc.direccion, tc.vendedor, tc.creacion from tmp_clientes tc where tc.cliente not in (select c2.cliente from clientes c2)

Tal vez incluso el campo indicado para hacer el where ... not in sea ese rif, pero deberías decirnos cuál es su naturaleza.