Ver Mensaje Individual
  #2 (permalink)  
Antiguo 15/04/2012, 12:57
Avatar de repara2
repara2
 
Fecha de Ingreso: septiembre-2010
Ubicación: München
Mensajes: 2.445
Antigüedad: 13 años, 7 meses
Puntos: 331
Respuesta: ¿Consulta sin datos duplicados entre dos tablas?

La explicación a este problema exacto se encuentra en la guía de Zend:

Código SQL:
Ver original
  1. The most common TYPE OF JOIN IS called an INNER JOIN. It works BY returning the ROWS
  2. FROM two TABLES IN which a common KEY expression IS satisfied BY BOTH TABLES. Here’s an
  3. example:
  4. SELECT *
  5. FROM table1 INNER JOIN table2 ON table1.id = table2.id
  6. WHEN executing this query, the DATABASE will look at the table1.id = table2.id con-
  7. dition AND ONLY RETURN those ROWS FROM BOTH TABLES WHERE it IS satisfied.You might think
  8. that BY changing the condition TO table1.id <> table2.id, you could find ALL the
  9. ROWS that appear IN one TABLE but NOT the other. IN fact, this causes the DBMS TO actually
  10. GO through each ROW OF the FIRST TABLE AND EXTRACT ALL the ROWS FROM the SECOND TABLE
  11. WHERE the id COLUMN doesn’t have the same VALUE, AND THEN do so FOR the SECOND ROW,
  12. AND so forth—AND you’ll END up WITH a resultset that contains every ROW IN BOTH TABLES
  13. many times OVER.
Utiliza left join para resoverlo. Saludos
__________________
Fere libenter homines, id quod volunt, credunt.