4
I have a launch line, in which this line would need to receive the value of the previous line +1, some example of how to do this?
Table structure:
CREATE TABLE `lancamento` (
`data` VARCHAR(10) NOT NULL,
`descricao` VARCHAR(30) NOT NULL,
`debito` DOUBLE(20,2) NOT NULL,
`credito` DOUBLE(20,2) NOT NULL,
`saldo` DOUBLE(20,2) NOT NULL,
`lancamento` DOUBLE(20,2) NOT NULL
) ENGINE=INNODB
You need to do this before entering the record?
– Roberto de Campos
It has to be all in SQL ? Where does the release data come from ?
– rbz
Yes, in this case you could do something like a SELECT by taking the value of the previous line and then adding it to 1 by receiving the value of the next line, the problem would be the SELECT in which you should select the previous line.
– Wel
am doing with php and mysql, the release would start at 1 and each run would generate a release, this release is just an identifier for control and also future changes.
– Wel
If you just leave the field like
AUTO INCREMENTO
doesn’t solve? Or you already have another fieldAUTO INCREMENTO
?– Roberto de Campos
Figure out how to do it?
– Wel
Put the structure of your table in the question so I can help you better. To get the structure, just run the command
SHOW CREATE TABLE nome_da_tabela
.– Roberto de Campos
lancamento
SELECT * FROMcaixa
WHERE 1– Wel
@Wel Execute this command
SHOW CREATE TABLE nome_da_tabela
and put here the result– Roberto de Campos
I’m not getting it very well, do you want to see the right output? it’s something like this
– Wel
Let’s go continue this discussion in chat.
– Roberto de Campos