SQL Server - Update with FROM and JOIN not considering all the rows that satisfies JOIN condition -


so, have 2 tables t1 , t2 in t1 has primary key column "a" unique values , t2 has foreign key "a" shown below.

t1 ---   conditionmet  1   0 2   0  t2 ---    b     c 1    10    5 1    20    20 2    10    10 2    30    0 

now, want update "conditionmet" column of t1 table "1" whenever value of column b in t2 equal value of colum c (for 1 specific value in a). update query below

update t1 set t1.conditionmet =    (case when t1.conditionmet = 0 , t2.b = t2.c 1 end)    t1 t1 inner join t2 t2    t1.a = t2.a 

here problem is not looping through rows of t2 going through first record value of "a". suppose if take value "1" in t1, @ first row (1 10 5) not @ second row (1 20 20) of t2. please me understand whats wrong query. in advance!!

try this....

update t1 set t1.conditionmet = case when t1.conditionmet = 0 , t2.b = t2.c                          1                     end       t1 t1 inner join t2 t2 on t1.a = t2.a not exists (select 1                    t2                   t1.a =                    , b <> c) 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -