Ver Mensaje Individual
  #5 (permalink)  
Antiguo 10/11/2009, 09:26
Avatar de huesos52
huesos52
Colaborador
 
Fecha de Ingreso: febrero-2009
Ubicación: Manizales - Colombia
Mensajes: 5.980
Antigüedad: 16 años, 1 mes
Puntos: 360
Respuesta: Resultados no coincidentes con JOIN

No sabría que decirte. haciendo pruebas con pocos registros fijate bien:

Código mysql:
Ver original
  1. mysql> SELECT * from tabla1 inner join tabla2 on tabla2.id_usuario = tabla1.id
  2.     -> where tabla1.desregistrado = 0;
  3. +----+---------+--------+-------+---------------+---------------------+---------+------------+----------+
  4. | id | id_foro | nombre | mail  | desregistrado | fechaingreso        | mailmd5 | id_usuario | id_grupo |
  5. +----+---------+--------+-------+---------------+---------------------+---------+------------+----------+
  6. |  1 |       1 | daniel | mail1 |             0 | 2009-11-10 10:19:43 | mail1   |          1 |        1 |
  7. |  1 |       1 | daniel | mail1 |             0 | 2009-11-10 10:19:43 | mail1   |          1 |        2 |
  8. |  1 |       1 | daniel | mail1 |             0 | 2009-11-10 10:19:43 | mail1   |          1 |        3 |
  9. |  1 |       1 | daniel | mail1 |             0 | 2009-11-10 10:19:43 | mail1   |          1 |        4 |
  10. |  2 |       1 | daniel | mail2 |             0 | 2009-11-10 10:19:51 | mail2   |          2 |        4 |
  11. |  3 |       1 | daniel | mail3 |             0 | 2009-11-10 10:20:00 | mail3   |          3 |        4 |
  12. |  4 |       1 | daniel | mail4 |             0 | 2009-11-10 10:20:46 | mail4   |          4 |        4 |
  13. +----+---------+--------+-------+---------------+---------------------+---------+------------+----------+
  14. 7 rows in set (0.00 sec)

Sin condición muestra 7 registros.

Código mysql:
Ver original
  1. mysql> SELECT * from tabla1 inner join tabla2 on tabla2.id_usuario = tabla1.id
  2.     -> where tabla1.desregistrado = 0 and tabla2.id_grupo = 4;
  3. +----+---------+--------+-------+---------------+---------------------+---------+------------+----------+
  4. | id | id_foro | nombre | mail  | desregistrado | fechaingreso        | mailmd5 | id_usuario | id_grupo |
  5. +----+---------+--------+-------+---------------+---------------------+---------+------------+----------+
  6. |  1 |       1 | daniel | mail1 |             0 | 2009-11-10 10:19:43 | mail1   |          1 |        4 |
  7. |  2 |       1 | daniel | mail2 |             0 | 2009-11-10 10:19:51 | mail2   |          2 |        4 |
  8. |  3 |       1 | daniel | mail3 |             0 | 2009-11-10 10:20:00 | mail3   |          3 |        4 |
  9. |  4 |       1 | daniel | mail4 |             0 | 2009-11-10 10:20:46 | mail4   |          4 |        4 |
  10. +----+---------+--------+-------+---------------+---------------------+---------+------------+----------+
  11. 4 rows in set (0.02 sec)

Con condición =4 muestra 4.

Código mysql:
Ver original
  1. mysql> SELECT * from tabla1 inner join tabla2 on tabla2.id_usuario = tabla1.id
  2.     -> where tabla1.desregistrado = 0 and tabla2.id_grupo <> 4;
  3. +----+---------+--------+-------+---------------+---------------------+---------+------------+----------+
  4. | id | id_foro | nombre | mail  | desregistrado | fechaingreso        | mailmd5 | id_usuario | id_grupo |
  5. +----+---------+--------+-------+---------------+---------------------+---------+------------+----------+
  6. |  1 |       1 | daniel | mail1 |             0 | 2009-11-10 10:19:43 | mail1   |          1 |        1 |
  7. |  1 |       1 | daniel | mail1 |             0 | 2009-11-10 10:19:43 | mail1   |          1 |        2 |
  8. |  1 |       1 | daniel | mail1 |             0 | 2009-11-10 10:19:43 | mail1   |          1 |        3 |
  9. +----+---------+--------+-------+---------------+---------------------+---------+------------+----------+
  10. 3 rows in set (0.00 sec)

Con condición <>4 muestra 3.

Desde donde haces las pruebas?
directamente en mysql o desde el lenguaje de programación?
__________________
Without data, You are another person with an opinion.
W. Edwads Deming