Xavizo Xavizo - 6 months ago 8
Java Question

Insert data to existing record

how can i insert and replace data in table to existing row from java, depends on ID?
I want to give statement like that

insert into rooms(status) values('occupied')
where id_room = 5;

Answer

You need to use update statement instead of insert.

Like that:

Update rooms set status = 'accupied' where Id = 5

So now the table will update the data with the new values.