Problem with MySql query inside PHP query

0

I have the following query in my php code

$consulta = "SELECT 
    p.universidad, 
    COUNT(c.cod_cita) as TOTALES, 
    SUM(CASE 
            WHEN p.universidad = 'Latina' 
            THEN 1 
            ELSE 0 
        END) AS latina,
    SUM(CASE 
            WHEN p.universidad = 'UAM' 
            THEN 1 
            ELSE 0 
        END) AS uam
FROM citas as c 
    JOIN pacientes as p
        ON c.cedulaFK = p.cedula 
        AND c.fecha_cita >= '$fecha1' 
        AND c.fecha_cita <= '$fecha2' 
WHERE 
    c.cod_sedeFK = 2
";


Las variables de $fecha1 y fecha2 las obtengo de aca: 
$fecha1 = $sesion->get("fecha1");
 $fecha2= $sesion->get("fecha2");

This query does not work like this, but if I change the dates in the query as follows:

AND c.fecha_cita >= '2018/12/01' 
AND c.fecha_cita <= '2018/12/31' //de esa manera si funciona.

I already proved that the variables $fecha1 and $fecha2 are "full", or that they have a date, however, it does not work

    
asked by Oscar Alberto Rodriguez 13.12.2018 в 02:20
source

0 answers