Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java JDBC UPDATE Add Number?

Tags:

java

mysql

jdbc

So let's say I have an int column in MySQL. I want to update that column by adding to it, without running a SELECT query to get the number and add it. Is this possible?


1 Answers

 update tablename set field = field + 1 where condition

This is a direct MySql update command to do so. You didn't mention if you were using a specific ORM like Hibernate or anything, but this same concept can be applied in HQL etc.

like image 51
BVSmallman Avatar answered May 31 '26 14:05

BVSmallman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!