开发者

How to add a fixed value to a int column in mysql without using SUM

开发者 https://www.devze.com 2023-03-24 21:58 出处:网络
I hav a simple query SELECT id from table1 I want to ad 20000 to each id but i don\'t want to use SUM() (That\'s because i can\'t use GRO开发者_如何学编程UP BY)

I hav a simple query

 SELECT id from table1

I want to ad 20000 to each id but i don't want to use SUM() (That's because i can't use GRO开发者_如何学编程UP BY)

How can i do that?


Not sure if you're asking to just SELECT the data or if you actually want to UPDATE the table, so I'll give both.

SELECT id + 20000 AS IncrementedId
    FROM table1

UPDATE table1
    SET id = id + 20000
0

精彩评论

暂无评论...
验证码 换一张
取 消