Reputation: 467
I know similar questions exist in which the user is trying to retrieve key generated of new row and the same thing as i want in PHP but i want to know its alternate for java. This is what i want:
String query = "UPDATE table SET tabValue = (tabValue+number) WHERE id="+xyz;
I want to retrieve the tabValue after it is being updated in the same query! Is it possible or do i have to write another query for it? Can anyone help me out here please? NOTE: I am using JDBC.
Upvotes: 1
Views: 1965
Reputation: 522719
From the MySQL documentation:
Currently, you cannot update a table and select from the same table in a subquery.
You cannot refer to the table
which is being updated in a FROM
clause.
You are better off just keeping track of what the new value will be after UPDATE
in your Java code.
Upvotes: 1