Following mysql query will give a result as follows
$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"
Result
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
Here I want to get the count
of each program_id
For eg:count(172),count(173) and so on.
id count
172 2