0
$result = $db->query("
SELECT RES.morada, RES.espaco, SUM(DATEDIFF(RES.data_fim, RES.data_inicio)*RES.tarifa) AS pago
FROM (
SELECT A.morada AS morada, A.codigo AS espaco, A.data_inicio, O.data_fim, O.tarifa
FROM Aluga A, Espaco E, Oferta O, Estado ES
WHERE A.morada ='IST' AND A.morada = E.morada AND A.morada = O.morada AND A.codigo = E.codigo AND A.codigo = O.codigo AND A.data_inicio = O.data_inicio AND A.numero = ES.numero AND ES.estado = 'Paga'
UNION
SELECT P.morada AS morada, P.codigo_espaço AS espaco, A.data_inicio, O.data_fim, O.tarifa
FROM Aluga A, Posto P, Oferta O, Estado ES
WHERE A.morada ='IST' AND A.morada = P.morada AND A.morada = O.morada AND A.codigo = P.codigo AND A.codigo = O.codigo AND A.data_inicio = O.data_inicio AND A.numero = ES.numero AND ES.estado = 'Paga'
) AS RES
GROUP BY RES.morada, RES.espaco;
insert what? error appears?
– rray
No error message appears, but I made a print after this query echo "went through here"
– user61898
and this message does not appear
– user61898
Do so to see if any error appears
$db->query("consulta longa...") or die($db->error);
oror die(print_r($db->errorInfo()));
is using PDO or Mysqli?– rray
I’m using PDO
– user61898