以下mysql查询将给出如下结果
$query = "SELECT PS.user_id, PS.pro_id
FROM pro_Purchase AS PS
INNER JOIN program_detail AS PD ON PD.program_master_id = PS.pro_id
WHERE PD.program_type = 'program'
AND PS.subscribe_status = '1'
GROUP BY PS.`programs_subscribed_id`
HAVING COUNT( `pro_id` ) > '1'
ORDER BY PS.pro_id"
结果
user_id program_id
97 167
12 172
12 172
216 173
216 173
215 173
216 173
12 173
12 173
12 173
216 173
在这里我想得到count
每个program_id
例如:count(172),count(173) 等等。
id count
172 2