Results 1 to 2 of 2
  1. #1
    Join Date
    May 2009
    Posts
    10

    Unanswered: Response in same order as array?

    SELECT * FROM `destinations` WHERE (ID in (529696,509781,512053,519351,523615))

    How can I make it return values in same order as they appear in brackets () ?
    Because although 509781 is second, its result comes first.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    use the FIELD function

    ... ORDER BY FIELD(ID,529696,509781,512053,519351,523615)


    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •