I have two tables, normalized:
table1
id quality product_id
1 100 1
2 100 2
3 10 4
4 50 2
and
table2
product_id product material
1 tinder metal
2 gold metal
3 timber wood
4 stone rock
How can I get all items on the first table that are metal? I tried
select sum(quality) from table1 join table2 on table2.material = 'metal';
but it seems that is not correct (720), it should be 250.
select table1.* from table1 join table2 using (product_id) where table2.material = 'metal';