Bladephp: Now with 8+ codeigniter, php, and laravel project 8+ php project From $37/Month From Rs. 2499/Month

Mysql GROUP BY Query

by
Category:mysql
php mysql
Mysql GROUP BY Query

You can use GROUP BY to group values from a column, and, if you wish, perform calculations on that column. You can use COUNT, SUM, AVG, etc., functions on the grouped column.

The GROUP BY query is often used with aggregate functions (COUNT, SUM, AVG) to group the result-set by one or more columns.

First you can need database connection in php

Code

$sql = "SELECT SUM(price) as totalprice FROM Products  GROUP BY userid"; 
$result = mysqli_query($con,$sql);
while($row = mysqli_fetch_assoc($result))
{

}

0 Comments


Html code work in comment box


Related Post