$sql = "INSERT INTO USUARIOS (partidas,partidas_ganas,turnos)
VALUES ((select partidas FROM usuarios WHERE nombre like='$nombre') + 1,
(SELECT partidas_perdidas FROM usuarios WHERE nombre LIKE = '$nombre') + 1)";
$sql = "INSERT INTO USUARIOS (partidas,partidas_ganas,turnos)
VALUES ((select partidas FROM usuarios WHERE nombre like='$nombre') + 1,
(SELECT partidas_perdidas FROM usuarios WHERE nombre LIKE = '$nombre') + 1)";
It is possible to insert data using those subqueries. But if you look at the VALUES you are only inserting 2 of the 3 columns, games and games_won , leaving out turns so it won't let you perform the insert. To compensate for this, if a value doesn't go, use a 0.
I hope my answer helps you, greetings.
You can use an insert into select , 'turns' I don't know its value
If you can, because you use sub-queries, you just have to put together your query well. If you are going to insert three data, you must send the three data to it. for instance:
Suppose we have a table called reps with the same structure as the employees table, and we want to insert into that table the employees whose title is rep sales
With the SELECT we obtain the rows corresponding to the employees with sales rep title, and we insert them in the repres table . Since the tables have the same structure, it is not necessary to put the list of columns and we can use * in the selection list of the SELECT .
Now suppose that the table reps had the following columns empnum , repoffice , repname . In this case we could not use the asterisk, we would have to put:
O well: