<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
bueno leo, me quedo con la ultima opcion y ya esta funcionando...<br><br>en la query solo agrego max(A.fecha_sesion) AS ultima <br>ests fecha la dinamito y la dejo en formato numerico (ejemplo 20100812), lo mismo hago con la fecha de hoy, <br>y en el &lt;td&gt; donde tengo el boton registar asistencia pongo un if, si registro una asitencia el boton cambia a presente porque la fecha de la ultima sesion es igual ahoy,<br>muchas gracias, <br>saludos<br>sigo laburando<br><br><br>&gt; From: leonardot@pegasusnet.com.ar<br>&gt; To: php-avanzado@pato2.fi.mdp.edu.ar<br>&gt; Date: Wed, 11 Aug 2010 18:36:15 -0300<br>&gt; Subject: Re: [Php-avanzado] consulta query<br>&gt; <br>&gt; Hola Bruno,<br>&gt; <br>&gt;         la primer opción te excluye a los que todavía no vinieron nunca, porque<br>&gt; para ellos A.fecha_sesion es NULL<br>&gt;         Una solución es agregar como condición OR que A.fecha_sesion = NULL<br>&gt;         Ojo! Vas a tener que encerrar las condiciones entre paréntesis para que<br>&gt; signifiquen lo que estamos hablando; algo así como<br>&gt; <br>&gt; AND (A.fecha_sesion&lt;'$fechahoy' OR A.fecha_sesion=NULL)<br>&gt; <br>&gt;         o más claramente todavía:<br>&gt; <br>&gt; AND ((A.fecha_sesion&lt;'$fechahoy') OR (A.fecha_sesion=NULL))<br>&gt; <br>&gt;         En el caso del LEFT JOIN, también deberías agregar que pueden ser<br>&gt; nulos...<br>&gt; <br>&gt;         Otra solución que pensé en la respuesta pasada pero no te dije, es que<br>&gt; la interfaz muestre a todos los de hoy, pero si A.fecha_sesion ==<br>&gt; '$fechahoy', aparezca un "presente" en lugar del botón de tomar<br>&gt; asistencia.<br>&gt;         Con esto mostrarías todos los del día, pero los que ya vinieron no se<br>&gt; pueden volver a usar, a la vez que se ve el día completo siempre.<br>&gt; <br>&gt;         Saludos!<br>&gt; <br>&gt; El mié, 11-08-2010 a las 18:54 +0000, Bruno Meschini escribió:<br>&gt; &gt; bien hay algo que no funciona,,,, estoy trabajando dos opciones...<br>&gt; &gt; <br>&gt; &gt; la primera...<br>&gt; &gt; <br>&gt; &gt; SELECT R.*, D.*, P.id_paciente, P.nombre, P.apellido,<br>&gt; &gt; count(A.id_rehabilitacion)AS presentes, A.fecha_sesion<br>&gt; &gt;                                         FROM (rehabilitaciones AS R,<br>&gt; &gt; dias_rehabilitaciones AS D, pacientes AS P)<br>&gt; &gt;                                         LEFT JOIN asistencias AS A ON<br>&gt; &gt; R.id_rehabilitacion= A.id_rehabilitacion<br>&gt; &gt;                                           WHERE R.id_rehabilitacion =<br>&gt; &gt; D.id_rehabilitacion<br>&gt; &gt;                                           AND R.id_paciente =<br>&gt; &gt; P.id_paciente<br>&gt; &gt;                                           AND D.id_dia=".$dia."<br>&gt; &gt;                                           AND (R.horario &gt;='$h1') AND<br>&gt; &gt; (R.horario &lt;= '$h2')<br>&gt; &gt;                                           AND (R.fecha_comienzo<br>&gt; &gt; &lt;='$fechahoy')<br>&gt; &gt; <br>&gt; &gt; <br>&gt; &gt;                                            AND<br>&gt; &gt; A.fecha_sesion&lt;'$fechahoy'<br>&gt; &gt; <br>&gt; &gt; <br>&gt; &gt;                                           GROUP BY A.id_rehabilitacion<br>&gt; &gt;                                           ORDER BY horario<br>&gt; &gt; <br>&gt; &gt; <br>&gt; &gt; <br>&gt; &gt; Agregando este AND A.fecha_sesion&lt;'$fechahoy'   la consulta me excluye<br>&gt; &gt; los pacientes que aun no tienen registros en asistencia, <br>&gt; &gt; pero tienen que venir...<br>&gt; &gt; <br>&gt; &gt; <br>&gt; &gt; <br>&gt; &gt; la segunda  entonces lo pongo en LEFT JOIN <br>&gt; &gt; <br>&gt; &gt; <br>&gt; &gt; SELECT R.*, D.*, P.id_paciente, P.nombre, P.apellido,<br>&gt; &gt;                                count(A.id_rehabilitacion)AS presentes,<br>&gt; &gt; A.fecha_sesion<br>&gt; &gt;                                         FROM (rehabilitaciones AS R,<br>&gt; &gt; dias_rehabilitaciones AS D, pacientes AS P)<br>&gt; &gt;                                         LEFT JOIN asistencias AS A ON<br>&gt; &gt; R.id_rehabilitacion= A.id_rehabilitacion AND<br>&gt; &gt; A.fecha_sesion&lt;'$fechahoy'<br>&gt; &gt;                                           WHERE R.id_rehabilitacion =<br>&gt; &gt; D.id_rehabilitacion<br>&gt; &gt;                                           AND R.id_paciente =<br>&gt; &gt; P.id_paciente<br>&gt; &gt;                                           AND D.id_dia=".$dia."<br>&gt; &gt;                                           AND (R.horario &gt;='$h1') AND<br>&gt; &gt; (R.horario &lt;= '$h2')<br>&gt; &gt;                                           AND (R.fecha_comienzo<br>&gt; &gt; &lt;='$fechahoy')<br>&gt; &gt;                                           GROUP BY A.id_rehabilitacion<br>&gt; &gt;                                           ORDER BY horario<br>&gt; &gt; <br>&gt; &gt; <br>&gt; &gt; <br>&gt; &gt; <br>&gt; &gt; aqui solo me excluye la sesion cuya fecha coincide con el dia de hoy<br>&gt; &gt; pero me sigue listando el paciente <br>&gt; &gt; <br>&gt; &gt; <br>&gt; &gt; <br>&gt; &gt; <br>&gt; &gt; &gt; From: leonardot@pegasusnet.com.ar<br>&gt; &gt; &gt; To: php-avanzado@pato2.fi.mdp.edu.ar<br>&gt; &gt; &gt; Date: Wed, 11 Aug 2010 15:01:55 -0300<br>&gt; &gt; &gt; Subject: Re: [Php-avanzado] consulta query<br>&gt; &gt; &gt; <br>&gt; &gt; &gt; El mié, 11-08-2010 a las 16:46 +0000, Bruno Meschini escribió:<br>&gt; &gt; &gt; &gt; gracias leo, ahora lo agrego..<br>&gt; &gt; &gt; <br>&gt; &gt; &gt; Después contanos...<br>&gt; &gt; &gt; <br>&gt; &gt; &gt; &gt; te escribi a tu mail hace unos dias,, parece que no lo viste,,,<br>&gt; &gt; ahora<br>&gt; &gt; &gt; &gt; te lo reenvio..<br>&gt; &gt; &gt; <br>&gt; &gt; &gt; Ok. Lo busco...<br>&gt; &gt; &gt; <br>&gt; &gt; &gt; &gt; saludos,<br>&gt; &gt; &gt; <br>&gt; &gt; &gt; =mente!<br>&gt; &gt; &gt; -- <br>&gt; &gt; &gt; <br>&gt; -- <br>&gt; <br>&gt; Leonardo Tadei<br>&gt; leonardot@pegasusnet.com.ar<br>&gt; http://blog.pegasusnet.com.ar<br>&gt; Firma pública: http://www.pegasusnet.com.ar/LeonardoTadei-public.key<br>&gt; <br>&gt; _______________________________________________<br>&gt; Php-avanzado mailing list<br>&gt; Php-avanzado@pato2.fi.mdp.edu.ar<br>&gt; http://www3.fi.mdp.edu.ar/cgi-bin/mailman/listinfo/php-avanzado<br>                                               </body>
</html>