Table:
laterecords
-----------
studentid - varchar
latetime - datetime
reason - varchar
My request:
SELECT laterecords.studentid,
laterecords.latetime,
laterecords.reason,
( SELECT Count(laterecords.studentid) FROM laterecords
GROUP BY laterecords.studentid ) AS late_count
FROM laterecords
I get the error "MySQL subquery of more than one row".
I know a workaround for this request to use the following request:
SELECT laterecords.studentid,
laterecords.latetime,
laterecords.reason
FROM laterecords
Then, using php loop, although we get the results, and make a request below to get late_countand execute the echo code:
SELECT Count(laterecords.studentid) AS late_count FROM laterecords
But I think there might be a better solution?
source
share