I have two tables one called customer and the other called referrals I need to add some numbers to two columns in table "referrals" but to know which ones, I need to refer the the table "customer" since its the one that has the group_id.
Here's an example of what I tried
UPDATE referrals AS r
SET total_coins_received = r.total_coins_received + 2, unused_ref_coins = r.unused_ref_coins + 2
FROM customer AS c
WHERE c.group_id = '1' and c.subscription_state = 'active';
This ignored my WHERE state and updated all the fields even if it didn't match the "group_id"
How can I just reference that I need to just change the ones that apply to the conditions?
This is a fiddle with an example of what is happening: https://www.db-fiddle.com/f/4jyoMCicNSZpjMt4jFYoz5/239
customer ctable. Is that your intention? Also, it is not associated with thereferrals rtable. Is that your intention?