M
M
m1chnt2020-11-20 19:33:37
MySQL
m1chnt, 2020-11-20 19:33:37

Why is 1 not added to 0 in mysql?

let activ = row[0].activated
let one = 1
con.query(`UPDATE promocode SET activated = ${activ} + ${one} WHERE promo = ${promo}`)
moreover, if the number of activations in the database will be, not 0, but 1, then it will add 1 and there will be two. but if the number is 0 and it adds 1, then the number in the base remains 0.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Slava Rozhnev, 2020-11-21
@rozhnev

I can advise the following query to increment the counter:

con.query(`UPDATE promocode SET activated = activated + 1 WHERE promo = ${promo}`)

Use SQLize.online to check SQL query

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question