in reply to Re: Re^3: Foreach Problem! Help!!!
in thread Foreach Problem! Help!!!

Your results do not come out in the order you expect because you are doing multiple queries in arbitrary order. You are doing one query for each value in %expal.

It is not the same thing to do this:

SELECT * FROM foo WHERE expal = 5 ORDER BY expal; SELECT * FROM foo WHERE expal = 3 ORDER BY expal; SELECT * FROM foo WHERE expal = 2 ORDER BY expal; SELECT * FROM foo WHERE expal = 4 ORDER BY expal; SELECT * FROM foo WHERE expal = 1 ORDER BY expal;
as it is to do
SELECT * FROM foo WHERE expal IN (5,3,2,4,1) ORDER BY expal;
Your code is effectively doing the former. You seem to want it to do the latter.

The PerlMonk tr/// Advocate