如何使用 GROUP mysql bind_param 计算行数?
桌子 :check
.
__________________________
| id | product_id | user |
| 1 | 123 | test |
| 2 | 456 | test |
| 3 | 456 | test |
| 4 | 123 | test |
| 5 | 789 | test |
这是我的代码
<?PHP
$username = "test";
$sql = 'SELECT COUNT(*) FROM check WHERE user = ? GROUP BY product_id';
$statement = $db_mysqli->prepare($sql);
$statement->bind_param('s', $username);
$statement->execute();
$result = $statement->get_result();
$row = $result->fetch_row();
$all_product = $row[0];
echo $all_product;
?>
当我测试代码时,5我想知道我该怎么做才能展示3 group by product_id