Hi, i've a problem to get the total number of result records from a database. This is my actual query
"SELECT m.*,
(
SELECT count(1) FROM votazioni_messaggi v
WHERE v.idMessaggio=m.ID
AND v.userID='$uID'
) AS Votato,
(
SELECT count( * ) FROM messaggi m
WHERE m.Scadenza>'$Orario'
) AS totale,
AVG(voto) AS votazioneMedia,
FROM messaggi m
LEFT JOIN votazioni_messaggi v ON v.idMessaggio = m.ID
WHERE m.Scadenza>'$Orario'
LIMIT $partenza, 20";
Assuming that i convert it in a JSON object, i successful retrieve the "total" of the records, but it's such nested inside each item of the result.
Exemple:
-0
--title
--message
--user
--total
-1
--title
--message
--user
--total
-2
--title
--message
--user
--total
and so on...
Instead, i want to treat it such a single instance.. How i can do that?