Good afternoon! I have a SQL query, which fetches and adds the amount of credits a given user has:
SELECT *, SUM(quantidade) as total_creditos FROM creditos INNER JOIN usuarios ON creditos.id_usuario = usuarios.id WHERE creditos.id_usuario = '$id_usuario''
In the credits table, I have the following structure:
A user can have multiple inserts in the table, with X credits.
The question is: how can I make a query and decrease (delete) a Y value of a user's total SOMA credits?
Thank you in advance!