Есть 3 таблицы:
purchases
+------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| user_id | int(11) | NO | | NULL | |
| account_id | int(11) | NO | | NULL | |
| amount | int(11) | NO | | NULL | |
| status | varchar(32) | NO | | NULL | |
| time | int(11) | NO | | NULL | |
+------------+-------------+------+-----+---------+----------------+
products
+-------------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+---------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | text | NO | | NULL | |
| description | text | NO | | NULL | |
| price | int(11) | NO | | NULL | |
+-------------+---------+------+-----+---------+----------------+
accounts
+------------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| product_id | int(11) | NO | | NULL | |
| number_id | int(11) | NO | | NULL | |
| status | varchar(16) | NO | | NULL | |
+------------------+-------------+------+-----+---------+----------------+
Необходимо получить ответ для всех products с, собсна, ID product'а и кол-вом успешных purchases (status = 'confirmed')
Мучаюсь-с уже пару часов.
Заранее спасибо)