varsha dodiya

varsha dodiya

  • NA
  • 407
  • 75.4k

check for column value and update value in that row in sql

Aug 6 2014 5:33 AM
geeks,
plz help me with sql query
i have a table like this
p_nameqty
batchno
vendor Odr flag
 disprin 20 b5 A ordered
 crocin 5 d3 B null
 disprin 12 b6 B
 ordered
 (new insert)
 2g3
w
 null
you see here disprin is indicating ordered from Odr flag
while crocin has null value in odr flag as not been ordered yet .
now i want when i insert another entry (for example disprin) then query checks if its Odr col has value 'Ordered' then update it as null in all the rows having P_name 'disprin' . 
so on inserting disprin it should be like this
p_nameqty
batchno
vendor Odr flag
disprin 20 b5 A null
crocin 5 d3 B null
disprin 12 b6 B
null
disprin
2g3
w
null
 help me guys. any help will be appreciated .
 

Answers (3)