Maintain WHERE Order In SQL Select -


Is it possible to maintain the order of the WHERE clause while SELECT for specific records?

For example, the following selection statements were given:

  SELECT [RecSeq] FROM [MyData] WHERE [RecSeq] = 3 or [RecSeq] = 2 or [RecSeq ] = 1 or [Rick Siec] = 21 or [Riccik] = 20 or [Rick Siec] = 1 9 or [Rick Cec] = 110 or [RECSE] = 109 or [RECSSE] = 108 or [RECEc] = 53 or [RECEAAC] = 52 or [RECSE] = 51;  

I want to return the result:

  3 2 1 21 20 19 110 109 108 53 53 51  

However, whatever I am getting back to is not in any particular order. Currently I have a loop that calls the selection statement for each record required. It can range from 1 to 700,000 times anywhere, saying that performance is the best.

Any solution or am I stuck in the loop?

You need ORDER BY FIELD .

  Select RECeq from MyData where the RECeq IN (3, 2, 1, 21, 20, 19, 110, 109, 108, 53, 52, 51) Order of Field (Rick) Sack, 3, 2, 1, 21, 20, 19, 110, 109, 108, 53, 52, 51);  

You do not say that which database system you are using - I know that works in MySQL.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -