Problem while using in operator

  • HI all,

    i am facing a problem while passing arguments using in operator

    i have a master table colors and a transaction table colordetails

    select Colorname as ColorName from colors where colorid in(3,6,37,0,0,0)

    select Colorname as ColorName from colors where colorid in(6,37,3,0,0,0)

    this is the query

    when we are using in operator it sorts and retrieves the record.

    but my requirement is that the order should not be changed..

    Help me

    Thanks

    Shankar.N

  • shankartup (7/28/2008)


    HI all,

    i am facing a problem while passing arguments using in operator

    i have a master table colors and a transaction table colordetails

    select Colorname as ColorName from colors where colorid in(3,6,37,0,0,0)

    select Colorname as ColorName from colors where colorid in(6,37,3,0,0,0)

    this is the query

    when we are using in operator it sorts and retrieves the record.

    but my requirement is that the order should not be changed..

    Help me

    Thanks

    Shankar.N

    There is no "order by" in your query so SQL Server will give you the results in the order it feels like. You can only prevent this by adding an "order by" to your query. e.g.

    select Colorname as ColorName from colors where colorid in(3,6,37,0,0,0) order by Colorname

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

  • Do you want the results in order by the color id?

    Or do you want the results returned in the input order?

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply