(shameless plug for a tool that I wrote :) This sort of "flat file join" is the kind of thing I've had to do quite often over the years -- not just the intersection on a key field, like you're doing, but also unions and diffs, with flexible field delimiters (regex) and flexible output.
So I wrote my own generalized command-line tool to do this, and have been adding features every now and then. It's posted here: cmpcol (and I've just updated that node to include stuff I've added to the script since the original posting).
Given your two data files (call them t1 and t2), I can generate the output you specified with this command line:
cmpcol -i -lb -d \; t1:2 t2
Where:
- "-i" means "output the intersection"
- "-lb" means "list full contents of matching lines from both files" (concatenate with no separator string)
- "-d \;" means the input field delimiter is semi-colon (have to use "\;" so the shell won't interpret ";" as a command separator)
- "t1:2" means "match on the second field of file t1"
- "t2" implies "match on the first field of file t2"