Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Order of parameters passed in the "WHERE IN clause" should not change

Nancy4444Nancy4444 Posts: 1Member
Hi All,

I have a table named Temp_Table which has 6 rows, like below example:

[color=Blue][b]Col1 Col2[/b]
1 AAAA
2 BBBB
3 CCCC
4 DDDD
5 EEEE
6 FFFF[/color]

My query is: [color=Red]Select * from Temp_Table where Col1 in (3,6,1)[/color]
The result which is get is:
[color=Blue] [b]Col1 Col2[/b]
1 AAAA
3 CCCC
6 FFFF[/color]

But I am expecting the result to be in the same order of what is passed in the IN clause, like below:
[color=Blue][b]Col1 Col2[/b]
3 CCCC
6 FFFF
1 AAAA[/color]

How can i do this with a SQL query, am i going wrong with using the IN clause. Please help me solve this issue, I am a c# developer with very little knowledge about query... And I am using SQL Server

Thanks,
Nancy
Sign In or Register to comment.