SELECT r.id_member,r.id_type, COUNT( r.id_member ) , m. *
FROM tb_register r
JOIN tb_member m
ON r.id_member = m.id_member
AND r.id_type =1
AND m.level_member =1
AND m.year_member =$year_in
GROUP BY r.id_member
SELECT MAX(C1) M1 FROM
(SELECT r.id_member,r.id_type, COUNT( r.id_member ) C1 , m. *
FROM tb_register r
JOIN tb_member m
ON r.id_member = m.id_member
AND r.id_type =1
AND m.level_member =1
AND m.year_member =$year_in
GROUP BY r.id_member
) AS T1
SELECT MAX( C1 ) M1
FROM (SELECT r.id_member, r.id_type, COUNT( r.id_member ) C1, m. *
FROM tb_register r
JOIN tb_member m ON r.id_member = m.id_member
AND r.id_type =1
AND m.level_member =1
GROUP BY r.id_member
) AS T1
LIMIT 0 , 30
ผมลองเอาโค๊ดที่ให้มาไปรัน ที่ phpMyAdmin มันแจ้งแบบข้างล่างครับ
MySQL แสดง:
SELECT MAX( C ) M
FROM (
SELECT r.id_member, r.id_type, COUNT( r.id_member ) C, m.name_member
FROM tb_register r
JOIN tb_member m ON r.id_member = m.id_member
AND r.id_type =1
AND m.level_member =1
GROUP BY r.id_member
) AS T