我想计算从查询中选择的行数以及所选数据。
SELECT `student`.`student id` AS ID,
`student unit enrolment`.`session`,
`student unit enrolment`.`unit code`,
`units`.`unit name`,
`workshops`.`campus`,
`workshops`.`location`,
CONCAT (
`teachers`.`first name`,
" ",
`teachers`.`last name`
) AS Tutor
FROM `student`,
`student unit enrolment`,
`units`,
`workshops`,
`teachers`
WHERE `student`.`student id` = `student unit enrolment`.`student id`
AND `student unit enrolment`.`unit code` = `units`.`unit id`
AND `student unit enrolment`.`unit code` = `workshops`.`unit code`
AND `workshops`.`teacher id` = `teachers`.`staff id`;
答案 0 :(得分:0)
试试这个:
$result = mysql_query(YOUR_QUERY_HERE);
mysql_num_rows($result);
答案 1 :(得分:0)
select `student`.`student id` as 'Student ID' , `student unit enrolment`.`session` , `student unit enrolment`.`unit code`
, `units`.`unit name` , `workshops`.`campus` , `workshops`.`location` , CONCAT(`teachers`.`first name`, " " , `teachers`.`last name`) as Tutor ,
(select count(`student`.`student id`)
from `student` , `student unit enrolment` , `units` , `workshops` , `teachers`
where `student`.`student id` = `student unit enrolment`.`student id` and `student unit enrolment`.`unit code` = `units`.`unit id`
and `student unit enrolment`.`unit code` = `workshops`.`unit code`
and `workshops`.`teacher id` = `teachers`.`staff id`
and `student unit enrolment`.`Year` = '2014') as 'Total count of students'
from `student` , `student unit enrolment` , `units` , `workshops` , `teachers`
where `student`.`student id` = `student unit enrolment`.`student id`
and `student unit enrolment`.`unit code` = `units`.`unit id`
and `student unit enrolment`.`unit code` = `workshops`.`unit code`
and `workshops`.`teacher id` = `teachers`.`staff id`
and `student unit enrolment`.`Year` = '2014'
Order by `student unit enrolment`.`session` , `student unit enrolment`.`unit code` , `workshops`.`location` , `workshops`.`class times`