UPDATE VS4TAPVDocRefAOL SET TPDATJstLn=(select tjstln from vs4tjobmethod where TJStTJbMTJobNo=TPDATJobNo 
and TJStTSepCode=(select TJCSTSepCode from vs4tjobcostsheet where TJCSTJbMTJobNo=TPDATJobNo  and tjcsln=TPDATJCSLn))
WHERE TPDATJstLn=0 or TPDATJstLn is null
GO