Hi,
I have this Query : SELECT field_name FRM meta WHERE id IN ('13','11','7','8','9','10','12')
I want the rows to be display in the same order as the IN list
of ids.Any ideas?
All the best wished,
Regards and Thanks,
Pong
2 3171
Hi,
I have this Query : SELECT field_name FRM meta WHERE id IN ('13','11','7','8','9','10','12')
I want the rows to be display in the same order as the IN list
of ids.Any ideas?
All the best wished,
Regards and Thanks,
Pong
Will this work? -
SELECT
-
field_name FRM meta WHERE id IN ('13','11','7','8','9','10','12')
-
order by case
-
when id = 13 then 1
-
when id = 11 then 2
-
else id
-
end
-
if not put in a subquery - (SELECT top 100 PERCENT
-
sortid = case
-
when id = 13 then 1
-
when id = 11 then 2
-
else id
-
end,
-
field_name FRM meta WHERE id IN ('13','11','7','8','9','10','12'))
-
order by sortid
-
try the first one first. it's faster
--CK
You could also consider putting the values inside the "IN" statement in their own table. Then you could solve the problem by doing a simple join, and order by the identity ID in the new table.
If performance is important, this is a solution worth considering.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Donald Firesmith |
last post by:
How do I use XSL to generate and XHTML list of hyperlinks stored in XML?
My XML contains links of examples of the form:
<examples>
<example>
<link url="aURL">some text</link>
<info>some more...
|
by: Perry Shindle |
last post by:
Does anyone no where I can get the latest, up-to-date list of valid
values for the CLI PATCH2 keyword? I followed the current link in the
on-line DB2 UDB Information Center and it led me to PATCH2...
|
by: Dave Theese |
last post by:
Hello all,
Our organization is considering a move from C++ to C#. I've been asked to
compile a list of the better C# references, but I am new to C# and so don't
really know which references...
|
by: Homa |
last post by:
Hi to all,
My database has two tables: order and orderItem. the order table has
(idOrder, name, address, etc) and the orderItem table has (idOrder,
idProduct, Quantity)
I want to present the...
|
by: Brian Henry |
last post by:
I have a list box bound to a data set, of course the datasource,datamember,
and valuemember are set, i tell it selecteditem = -1 to make nothing
selected, select mode is set to only one item at a...
|
by: federicog |
last post by:
I have to create a listing in random order from a few mysql tables.
I can't use ORDER BY RAND() for a few reasons:
- The random order has to change only every 24hs, ie: today it will show rows...
|
by: supermancc03 |
last post by:
I have a List<Point> X(Point pos) which returns a list of coordinates of "neighboring cells" I also have a function getY(int x, int y) that takes in a set of points and returns me a double. I need...
|
by: Academia |
last post by:
I've spent the last hour searching the internet for a simple list of the
shortcut keys recognized by the Windows Forms RichTextBox and came up empty
handed.
I did see where someone mentioned...
|
by: Cyprus106 |
last post by:
I've got a statement as follows that grabs matching records out two tables:
"SELECT * FROM BKRETAIL WHERE BKRETAIL.MATK='THISTHE' UNION SELECT * FROM BKMASTER WHERE BKMASTER.MATK='THISTHE';
My...
|
by: suneelkn |
last post by:
Unable to identify the same level for nested lists in all scenarios, when the nested-list inside an ordered list the conversion process executes with out proper list order for nested list items. The...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |