Updating data in SQL

3

I have a table with the following fields: Nome(VARCHAR) , Email(VARCHAR) , Credito(INT)

I wanted to know how, or with what command, to decrease or increase the Credito field.

I know you have to use UPDATE but I've already tried several ways and I could not.

    
asked by anonymous 13.12.2014 / 21:10

1 answer

6

You did not give too many details of what you are using, nor did you show what you tried so I will give you a generic answer to increment the value of one to the field in MySQL which I think is the likely DB you are using focus more on your question):

$sql = "UPDATE tabela SET Credito = Credito + 1 WHERE Email = '$email'";
$resultado = mysqli_query($conexao, $sql)

I placed GitHub for future reference .

I'm assuming that the variable is properly sanitized .

Or you can use a parameterized form to execute but the query SQL will be equal to this one.

    
13.12.2014 / 21:19