MySQL Forums
Forum List  »  Spanish

Re: Error MYSQL - Consulta con referencias cruzadas
Posted by: Enrico Renato Salcedo Herrera
Date: March 29, 2009 08:10PM

Hola, Gonzalo gracias por su sugerencia, lamentablemente sucede lo mismo:

select * from detalledi;
+------------+----------+------------+---------------------+
| FechaDis | DNIPI | Disponible | FechaHoraDDI |
+------------+----------+------------+---------------------+
| 2009-04-05 | 00253655 | 1 | 2009-03-28 19:28:44 |
| 2009-04-06 | 00253655 | 1 | 2009-03-28 19:28:24 |
| 2009-04-07 | 00253655 | 1 | 2009-03-28 17:26:43 |
+------------+----------+------------+---------------------+

SELECT
D.DNIPI,
IF(D.FechaDis='2009-04-06', D.disponible,0) AS 06Abril,
IF(D.FechaDis='2009-04-05', D.disponible,0) AS 05Abril,
IF(D.FechaDis='2009-04-07', D.disponible,0) AS 07Abril
FROM
detalledi D
GROUP BY
D.DNIPI;
+----------+---------+---------+---------+
| DNIPI | 06Abril | 05Abril | 07Abril |
+----------+---------+---------+---------+
| 00253655 | 0 | 1 | 0 |
+----------+---------+---------+---------+

Como puedes observar en la tabla los valores en todos los dias es de 1 para ese DNI, como 05Abril es el primer valor en la tabla si lo toma mas los demas son ignorados, en tu query la no encontrar devuelve 0.

Gracias Gonzalo, a ver si alguien mas me sugiere algo, lo apreciaria....

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Error MYSQL - Consulta con referencias cruzadas
3035
March 29, 2009 08:10PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.