Re:

From: Hemant Patel <hemant(dot)patel(at)impetus(dot)co(dot)in>
To: ries van Twisk <pg(at)rvt(dot)dds(dot)nl>
Cc: pgsql-sql <pgsql-sql(at)postgresql(dot)org>
Subject: Re:
Date: 2008-11-05 16:21:21
Message-ID: 33018C5018AA3042A227BBB6D9BF4A5C36E1A2B5A8@mail1.impetus.co.in
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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(at)rvt(dot)dds(dot)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:

Hello Everyone,

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.

Please help me in this....
Thanks in advance...

With Regards,
Hemant Patel

________________________________
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.

In response to

  • Re: at 2008-11-05 14:50:56 from ries van Twisk

Responses

  • Re: at 2008-11-05 17:14:42 from Scott Marlowe

Browse pgsql-sql by date

  From Date Subject
Next Message Scott Marlowe 2008-11-05 17:14:42 Re:
Previous Message ries van Twisk 2008-11-05 14:50:56 Re: