how to change a certain value of a column in a row without updating the whole row Java Derby Data Base

StackOverflow https://stackoverflow.com/questions/21743942

  •  10-10-2022
  •  | 
  •  

Pregunta

i have a row like that :

ID===Name===Price===Quantity

04===LCDs===630===20

now i am trying to subtract 1 or more each time someone buy a LCD from the database

what i am able to do with my knowledge is to :

-get data as a String and convert to int

-then subtract

-then execute this statement "UPDATE Store_HOUSE SET ID=04,Name='LCDs',Price=630,Quantity="+ newValue ;

that works well but iam sure there is a better way ... like if i can specify the exact column that will be changed instead of having to pass the whole row (which is lot more than what's in the Example =\ )to change only one column .

¿Fue útil?

Solución

Why don't you set the column type of Quanitty to INT?

then you can do it via update store_house set Quantity = Quantity - 1 where blabla...

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top