search

Home  >  Q&A  >  body text

Close: MySQL update query to increment specific value

How to increase and update mysql columns with the same value

Id name UpdateA(expected) Update B (expected)
1 AAAAA 1 1
2 AAAAA 1 2
3 AAAAA 1 3
4 BBBBB 2 1
5 BBBBB 2 2
6 CCCCCC 3 1
7 CCCCCC 3 2
8 CCCCCC 3 3
9 CCCCCC 3 4
10 CCCCCC 3 5

P粉129275658P粉129275658465 days ago627

reply all(1)I'll reply

  • P粉105971514

    P粉1059715142023-09-20 16:07:03

    Your question is unclear.

    If necessary, you can do this:

    UPDATE whatever_table 
       SET column_a = column_a + 1
     WHERE column_name = 'AAAAAA'
    

    This will increment a column in a ACID compliant manner.

    reply
    0
  • Cancelreply