When I query my Mysql table to get results. I get a tuple back.
The tuple is like this:
(('Book 1', 1), ('Book 2', 1), ('Book 1', 2))
How do I get my tuple to be like this:
(('Book 1', 3), ('Book 2', 1))
Any suggestions in python or SQL would be helpful.
>Solution :
you can try SQL group by statement with aggregate function ‘sum’
example
select book_name,sum(book_quantity)
from your_table_name
group by book_name