November 13, 2008 at 9:49 pm
I have 2 sql statements:
update t5
set updatefield = 0
from t5 inner join t6 on (t5.c1 = t6.d1)
and ( (t5.c2 =t6.c2) and (t5.c3 = t6.d3))
update t5
set updatefield = 1
from t5 inner join t6 on (t5.c1 = t6.d1)
and ( (t5.c2 <> t6.c2) or (t5.c3 <> t6.d3))
The inner join in the first update works on a certain set of values and the inner join in the second update works on the data missed by the first join.
Is there any way I can combine these two ststaments into one Join, one update?
TIA,
barkingdog
November 13, 2008 at 11:32 pm
UPDATE t5
SET UpdateField = CASE
WHEN t5.c2 = t6.c2 AND t5.c3 = t6.d3
THEN 0
ELSE 1
END
FROM t5
INNER JOIN t6
ON t5.c1 = t6.d1
--Jeff Moden
Change is inevitable... Change for the better is not.
November 14, 2008 at 12:35 am
Thank You Jeff.
November 14, 2008 at 11:26 am
You bet... thank you for the feedback.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply