postgresql - SQL update in one statement instead of two -
postgresql - SQL update in one statement instead of two -
is possible next in 1 statement instead of 2. need set isactive flag 1 id , set others false. im using postgres db.
tblnames ------------------------ id,name,isactive 1,'n1',true 2,'n2',false 3,'n3',false 4,'n4',false update tblnames set isactive = true id = 4 update tblnames set isactive = false id != 4
does work?
update tblnames set isactive = (id = 4) in case doesn't (i don't know postgres syntax enough), certainly work:
update tblnames set isactive case id when 4 true else false end sql postgresql
Comments
Post a Comment