I need to do
select * from xxx where name in (a,b,c...);
but I want the result set to be in order (a,b,c...). is it possible?
(a,b,c...)
I found this question that looks like your original question: Order in order of values in SQL IN () clause
ah - I see. you can do something terrible with the case argument and then arrange it. You would add another column to your query as an “order”, which you could then “arrange by”
its ugly, but if you control the request and the number in the in clause is low, it can work (the beleive condition in is limited to 255 characters)
e.g "IF name = a then 1 else if name = b then 2"
IF name = a then 1 else if name = b then
, , (, "in" ).
-ACE
.
Oracle - :
SELECT * FROM xxx where name in (a,b,c...) ORDER BY DECODE(name,a,1,b,2,c,3);
IN , , .
:
SELECT x.* FROM xxx as x INNER JOIN ((select a as name, 1 as ord) UNION (select b as name, 2 as ord) UNION (select c as name, 3 as ord)) as t ON t.name = x.name ORDER BY t.ord
, sql. ord . , SqlServer, ROWINDEX, .
Source: https://habr.com/ru/post/1749109/More articles:How to deduce csv from enumeration of anonymous type? - c #Serialization of configurations for dependency injection / inversion - dependency-injectionwhere does IValueConverter.Convert return the CultureInfo parameter? - wpfМожете ли вы использовать веб-службу в качестве источника данных для почтового отправления - web-servicesCreating a foreign key in MySQL results in an error: - sqlПользовательский компонент Swing: вопросы по подходу - javasql to choose from a large number of identifiers - pythonSQL gets data from BEGIN; ...; END; block in python - pythonChoose a many-to-many relationship in MySQL - mysqlWhat is the best way to integrate video chat into a website? - videoAll Articles