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

Howdy, Stranger!

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

Categories

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.