Scripting using flat files

I need some help to create a script that can do the following:

I have two flat files with one column that should link the two files' information into one record:

1st Flat File - 3 columns, multiple rows:

orderid, Jobnumber, Ordernumber

2nd Flat File - 2 columns, multiple rows:

Ordernumber, Member

By using the 'Ordernumber' to link these files together, I need the output in a seperate file like this:

Orderid, Jobnumber, Ordernumber, Member

Thanks for any assistance!

Are they in order? Which is larger?

They are not necessarily in order, but the files are the same size.

Thanks!

One possible solution would be to sort both files and use the join utlity.

Sudo code:

while read orderid Jobnumber Ordernumber
do
Member=grep ^Ordernumber file2 | awk print $2
print orderid Jobnumber Ordernumber Member
done <file1