First of all and VERY important: never build an SQL statement based on parameters that are sent in the POST. This results in problems of sql injection . Therefore, whenever parameters are passed to an SQL it should be as follows (using PDO ) :
$stmt = $pdo->prepare('UPDATE ventas SET ... WHERE id = :id');
$stmt->execute(array('id' => $valor_id));
$stmt->execute();
$result = $stmt->get_result();
In the example, the parameter is in the variable $valor_id
and is represented by the text :id
in the SQL statement.
Now, going to the problem and given the conditions you would have to answer that you can NOT perform the operation you want.
As mentioned in the comments of the question, there are several options to implement, and they depend a lot on some more data of the problem that they do not have in order to answer correctly.
Option 1
If for example you had a table similar to the following one (let's call it TablaX):
valor_id | procesador | valor_n
---------|------------|---------
xxx | 'intel' | yyy
aaa | 'amd' | bbb
you could do something like the following:
UPDATE ventas INNER JOIN TablaX
ON ventas.valor_id = TablaX.valor_id AND ventas.procesador = TablaX.procesador
SET ventas.ordenadores = TablaX.valor_n
Option 2
Another option would be to group values. This way you would not delete all the UPDATE but you would have less. For example, group all the updates of 'intel', then all of 'amd', etc.
I can think of something like the following:
UPDATE ventas
SET ordenadores = IF(valor_id = :valor_id1, :valor_n1, IF(valor_id = :valor_id2, :valor_n2, ..), ..),
WHERE procesador = 'intel'
Using something of the style, you could pass execute
a array
with all the possible values: id_value,: value_ni (with i from 1 to N the number of different values)
Surely there are more options but as already mentioned, it depends a lot on the context of the problem.
I hope it has been useful.
Greetings