I have the following table t
id a b c
1 1 1 1
2 2 1 1
and the table t1
id a b c p
1 1 1 1 47
2 1 1 1 2
3 2 1 1 78
My purpose is to get a table
id a b c p
1 1 1 1 49
2 2 1 1 78
I tried the following script but it not works @y=@y+t1.p is always null :
select t.id,t1.a, t1.b , t1.c ,@y=@y+t1.p from t1
inner join t
where t.a=t1.a
and t.b=t1.b
and t.c=t1.c
For more details enter link description here