Q:

Create a table row with value from multiple other rows

I'm creating a gift-list organizer website where the party host enters a product they want and its price. The party guests make 'pledges' until the total price is reached. 
I'm having trouble getting the total amount of pledges for a product.
I have a MySQL table for the product and a separate table for the pledges where to make the pledge, you have to enter the product ID.
That table stores every 'pledge' but I need to get the total amount of pledges for every product and '0' for the products that don't have pledges yet
I tried the mysql SUM query with the product id as a condition.
I was wondering if I could add a 'total in pledges' to the product table where it would be 0 as default for every product and then the pledges would be added to that.
This is the pledge database structure
#   Name          Type  
1   plIDPrimary  int(255)   
2   plEmail     varchar(255)                            
3   plAmount     double                     
4   prID         int(11)    

And this is the product
#   Name             Type
1   productID   int(11) 
2   pName         varchar(200)
3   pPrice          double  
4   pDesc         varchar(255)
5   pColor        varchar(255)  
6   pQuant          int(10) 
7   pURL          varchar(255)
8   eventID         int(255)    
9   pEmail        varchar(255)  

$sqlSUM = 'Select * FROM pledge where prID LIKE ... ';
$resultSUM = $db->query($sqlSUM);

I have a table with the products displayed on the website and I want to add another column with the total amount in pledges

A:

You want to get the total amount in pledges for each product. 
SELECT 
    pr.productID, 
    count(pl.prID) as totalPledge, 
    IFNULL(sum(pl.plAmount) ,0) as totalPledgeAmount 
FROM product pr 
LEFT JOIN pledge pl ON pr.productID = pl.prID 
GROUP BY pr.productID

Like this?

