To compare two columns

I have two pipe delimited files.

File1.txt & File2.txt

File1.txt

asd|dfg|ghjk
der|eikd|wkd
ret|joiol|wke

File2.txt

asd|ret|fkkf
ref|hfk|ks
ret|klsd|wr

I need to compare File1 & File2 based on column1 and pass the output to file3.txt( The matching records from File1 should go to File3.txt)

File3.txt should be like this

asd|dfg|ghjk
der|eikd|wkd
ret|joiol|wke

Can some one help on this

---------- Post updated at 12:42 PM ---------- Previous update was at 11:36 AM ----------

can some one please help !!!!!!

Your description of what you want done and your statement of what should be in File3.txt don't match. If you don't give us a clear description and example of what you want done, we can only waste time guessing at what you want to do.

For the sample input you provided and the sample output you say you want, the simple solution is the following command:

cp File1.txt File3.txt

A simple way to do what you said you wanted done (ignoring the samples your provided) would be something like:

awk -F "|" '
FNR == NR {f[$1] = $0;next}
$1 in f {print f[$1]}' File1.txt File2.txt > File3.txt