Request in MySQL in two tables [closed]

Just join, group by and sum(). Assuming that the foreign key column in table2 is t1_id:

select, sum(t2.cost) total_cost
from table1 t1
inner join table2 t2 on t2.t1_id =
group by,

If you want to allow names that have no match in table2, then use left join instead, and maybe coalesce(sum(t2.cost), 0) as well.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top