Dynamically prepare the condition using flat file sdata

I have a file in which the data looks like

A,B

My output should be

T1.A=T2.A
AND T1.B=T2.B

If my input is

A,B,C

My output should be

T1.A=T2.A
AND T1.B=T2.B
AND T1.C=T2.C

Currently I am automating my databae script and strucked with this part.Not able to search the exact requirement for this.

I think it can be doen using arrays and I am trying to do that.

Can anyone give me hints or approach?

$ echo "A,B,C" | awk -v RS="," -v ORS="\nAND " ' { print "T1."$1"=T2."$1 } '
T1.A=T2.A
AND T1.B=T2.B
AND T1.C=T2.C
$ echo "A,B,C" | sed "s/\([^,]*\)/T1.\1=T2.\1/g;s/,/\\
> AND /g"
T1.A=T2.A
AND T1.B=T2.B
AND T1.C=T2.C

Thank you very much.It helped a lot.How can i store the output into a variable?

---------- Post updated at 01:56 PM ---------- Previous update was at 01:50 PM ----------

Yeh.I got it.