ok the problem is that I have to sum two sums from two tables that are linked
first table points:
id | user_id | point | hit
1 | 1 | 4 | yes
2
If you want total earnings per user, you should probably start by identifying which users you want earnings for. The most sensible option is probably to use the users table itself as the basis.
SELECT user_id,
(SELECT SUM(point)
FROM points
WHERE user_id = u.user_id
)
+
(SELECT SUM(earning)
FROM earnings
WHERE user_id = u.user_id
AND p.hit IN ('yes', 'no')
) AS bb
FROM users
This approach has the added benefit of reporting on users who had no points and/or earnings.