i want to sum all total_harga by id_subkategori, how i caan get that? so just get for example all id_subkategori 5 get sum my database table
You can use GROUP BY id_subkategori
to get the desired output.
select sum(total_harga) total, id_subkategori
from yourtable
group by id_subkategori
You can read more on aggregate functions here
Edit:
If you want to pick for a specific id_subkategori, you need to change it like following.
select sum(total_harga) total, id_subkategori
from yourtable
where id_subkategori=5
group by id_subkategori
Use a sql statement to sum the total.
select sum(total_harga) total
from yourtable
where id_subkategori = 5
group by id_subkategori
Then fetch the sql result by PHP. Please check this for your reference.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.