question

keshar avatar image
keshar asked

update/replace in sql

I want to update or replace values in one table. like below:

createtable life_cal
(
    project varchar(10),
    type    varchar(10),
    life        int
)insertinto life_cal values('a1','house',100)insertinto life_cal values('a1','phone','')insertinto life_cal values('b1','building',120)insertinto life_cal values('b1','phone','')

Results in this data set:

project type    life
----------------------
a1     house    100
a1     phone    
b1     building 120
b1     phone    

I want to get a result like below:

project type    life
---------------------
a1     house    100
a1     phone    100
b1     building 120
b1     phone    120

On this above result it is updated based on type. if the type is like HOUSE, BUILDING then replaces/UPDATE the life of the PHONE accordingly base on the project.

It would be great if someone helps me with this. I tried a lot but could not get the correct answer.

Thank you in advance.

update_query
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.