Hi,
 
this is simple - but i do not know how many values you have
if this is small count then
 
select
Fields
FROM
TABLE_NAME
ORDER BY CASE WHEN ID=1032 THEN 1 WHEN ID=624 THEN 2 WHEN ID=2841 THEN 3 END
 
and if this is big numer then add better temp table with order values
 
regards,
Karol Bieniaszewski
 
W dniu 2014-11-19 22:50:22 użytkownik Caroline Beltran 
[email protected] [firebird-support] 
<[email protected]> napisał:
 
I hope that someone can advise how I can efficiently arbitrarily select data 
from a table.  I am provided with a list of IDs to display, for example:
 
Employee ID Numbers: 1032, 624, and 2841.
 
This would be the output (in the same order as the list above):
 
Employee ID FName LName
------------------  --------- ----------
1032             Frank  Burns
624               Jill      Applegate
2841             Angie  Cullens
 
The easiest and most obvious way to get this output is by using the SELECT 
statement 3 times:
 
SELECT id, fname, lname FROM employees WHERE id = 1032
SELECT id, fname, lname FROM employees WHERE id = 624
SELECT id, fname, lname FROM employees WHERE id = 2841
 
Please keep in mind that there is no criteria other than the ID and order 
provided in the list above.
 
Although this works, I would like to find the most efficient way to do this.  
My first though was to create a temporary table where I insert the 3 IDs and 
link them to the Employees table but that looks even less efficient.
 
What came to mind next was a STORED PROCEDURE. 
 
 What I would like to know is if it is possible to pass a variable amount of 
IDs and have the procedure parse each id and return the output as shown above? 
 
 If so, would this be the most efficient way to have Firebird fulfill this 
requirement?
 
Thank you

~-|**|PrettyHtmlStart|**|-~

Reply via email to