Let Say I have the array of primary key of some table say XYZ.
For e.g. (555,222,333,111)
When I query for these results I will get the result like in the order of (111,222,333,555) .
So now I need to process in the business logic to maintain the search criteria.
But I want the result from IIN query… the order I provide the ids
And if I will make query like ,
select * from XYZ where id=555 UNION ALL select * from XYZ where id=222 etc
Then it will return in that order.
so which one is better approach,
Or is there any other way…?
With Regards,
Hemant Patel
From: ries van Twisk [mailto:pg@rvt.dds.nl]
Sent: Wednesday, November 05, 2008 8:21 PM
To: Hemant Patel
Cc: pgsql-sql
Subject: Re: [SQL]
On Nov 5, 2008, at 8:42 AM, Hemant Patel wrote:
I have a array of ids from my search result and now I want to fetch the details from the database.
Now IN query is ruined my sort order.So should I go for Union All?
IN doesn't ruin your sort order really.... You need to think in sets...
Is there any other method to fetch the data..?
Can't you not directly join against you other table to fetch the result directly??
Show us the SQL you are working with + tables would help aswell.
NOTE: This message may contain information that is confidential, proprietary, privileged or otherwise protected by law. The message is intended solely for the named addressee. If received in error, please destroy and notify the sender. Any use of this email is prohibited when received in error. Impetus does not represent, warrant and/or guarantee, that the integrity of this communication has been maintained nor that the communication is free of errors, virus, interception or interference.
Impetus is the winner of the Economic Times Intel Smart Workplace Awards 2008 and the CNBC emerging India 2008. Visit www.impetus.com for details.