I have no idea what step 3 means, but all the other steps can be done in SQL, also, they probably should be done in SQL where its a lot more efficient.
I assume from your tags that you're using a MySQL database (it would have been helpful to know).
My initial thots would be somethnig along the lines of:
SELECT outdata.Pos,
outdata.OutData,
outdata.Warn,
MIN(outdata.Mismatch),
outdata.Producer,
outdata.Depl,
outdata.DeplOffMax,
outdata.DeplOffMin,
outdata.Axis
outdata.Connection
FROM outdata, indata
WHERE
(//some nasty type juggling here
outdata.depl='*'
OR outdata.deploffmin='*'
OR indata.depl='*'
OR (
outdata.depl<>'*'
AND outdata.deploffmin<>'*'
AND indata.depl<>'*'
AND outdata.depl-outdata.deploffmin>indata.depl
)
)
AND ( outdata.outdata=indata.outdata
OR outdata.outdata='*'
OR indata.outdata='*' )
AND ( outdata.connection=indata.connection
OR outdata.connection = '*'
OR indata.connection='*' )
AND (outdata.axis=indata.axis
OR outdata.axis='*'
OR indata.axis='*' )
....repeat for all the fields you want to match
GROUP BY outdata.Pos,
outdata.OutData,
outdata.Warn,
outdata.Producer,
outdata.Depl,
outdata.DeplOffMax,
outdata.DeplOffMin,
outdata.Axis
outdata.Connection
ORDER BY 4 ASC;
Simples.
C.