Ver Mensaje Individual
  #2 (permalink)  
Antiguo 04/04/2013, 12:54
Avatar de Libras
Libras
Colaborador
 
Fecha de Ingreso: agosto-2006
Ubicación: En la hermosa perla de occidente
Mensajes: 7.412
Antigüedad: 17 años, 8 meses
Puntos: 774
Respuesta: Subconsultas - NULL

Código SQL:
Ver original
  1. CREATE TABLE #table1
  2. (
  3. id INT,
  4. nombre VARCHAR(20),
  5. id_x INT
  6. )
  7.  
  8. CREATE TABLE #table2
  9. (
  10. id_x INT,
  11. telefono VARCHAR(20)
  12. )
  13.  
  14.  
  15.  
  16. INSERT INTO #table1 VALUES (1 ,'Guillermo' ,4)
  17. INSERT INTO #table1 VALUES (2 ,'Carlos' ,5)
  18. INSERT INTO #table1 VALUES (3 ,'Luis' ,6)
  19.  
  20. INSERT INTO #table2 VALUES (4 ,'2541667')
  21. INSERT INTO #table2 VALUES (5 ,'9696969')
  22. INSERT INTO #table2 VALUES (NULL ,'987654321')
  23.  
  24. SELECT t1.* FROM #table1 AS t1
  25. LEFT JOIN #table2 AS t2 ON (t1.id_x=t2.id_x)
  26. WHERE t2.id_x IS NULL

saludos!
__________________
What does an execution plan say to t-sql query? Go f**k yourself, if you are not happy with me