Join two files combining multiple columns and produce mix and match output

I would like to join two files when two columns in each file matches with each other and then produce an output when taking multiple columns.

Like I have file A

1234,ABCD,23,JOHN,NJ,USA
2345,ABCD,24,SAM,NY,USA
5678,GHIJ,24,TOM,NY,USA
5678,WXYZ,27,MAT,NJ,USA

and file B

ABCD,IND,GH,23,PIR,KUM
WXYZ,KKK,YU,27,OPI,UUU
TTTY,TTT,OP,31,IOP,RRR

and I want the output when column 2 and 3 of file A matches with Column 1 and 4 of file B; then produce output like below

fileA.column1,fileA.column3,fileB.column6,fileB.column1,fileA.column2,fileB.column1

Hello Mady135,

Following may help you in same.

awk -F, 'FNR==NR{A[$2 OFS $3]=FILENAME"."$1 OFS FILENAME"."$3;B[$2 OFS $3]=FILENAME"."$2;next} ($1 OFS $4 in A){print A[$1 OFS $4] OFS FILENAME"." $6 OFS FILENAME"." $1 OFS B[$1 OFS $4] OFS FILENAME"." $1}' OFS=, fileA fileB

Output willl be as follows.

fileA.1234,fileA.23,fileB.KUM,fileB.ABCD,fileA.ABCD,fileB.ABCD
fileA.5678,fileA.27,fileB.UUU,fileB.WXYZ,fileA.WXYZ,fileB.WXYZ

Thanks,
R. Singh

Try:

awk 'NR==FNR{B[$1,$4]=$6; next} ($2,$3) in B{print $1, $3, B[$2,$3], $2, $2, $2}'  FS=, OFS=, file2 file1

Are you sure that is what you want? Note that the last 3 fields are always going to be the same since fileA.column2 is always equal to fileB.column1