Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3321482
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:04:05+00:00 2026-05-17T23:04:05+00:00

I am looking to do an order by in a certain order. I know

  • 0

I am looking to do an order by in a certain order. I know I can modify the entire database but I would then need to modify the entire code base.

What I am have, is a column in a table ‘games’ called ‘status’.

So…

  SELECT * 
    FROM games 
ORDER BY status ASC  -- Will retrieve results going from 0 then 1 then 2

What I am looking for is to be able to order it by 1 then 0 then 2.

Any ideas???

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T23:04:05+00:00Added an answer on May 17, 2026 at 11:04 pm

    If I understand correctly, using a CASE expression:

      SELECT g.* 
        FROM GAMES g
    ORDER BY CASE g.status 
               WHEN 0 THEN 1
               WHEN 1 THEN 2
               WHEN 2 THEN 3
             END
    

    Using FIND_IN_SET function:

      SELECT g.* 
        FROM GAMES g
    ORDER BY FIND_IN_SET(g.status, '0,1,2')
    

    Using FIELD function:

      SELECT g.* 
        FROM GAMES g
    ORDER BY FIELD(g.status, 0, 1, 2)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am just looking at sorting an NSArray of NSNumbers into numeric order but
I am looking for a Java framework which can validate order of elements in
I would like to know (using C#) how I can delete files in a
Looking at options for embedding the 3D Secure page inside my own order form,
I'm looking to do a SELECT with an ORDER BY on a VARCHAR(200) field.
I'm looking for an exhaustive, university-level book or guide to study in order to
Is it possible to order an NSMutableArray where it's values are NSStrings? I'm looking
I'm looking at some older Perl code on Perl Monks to figure out programming
Looking for a good set of base objects to start a website up in
I have been taught at school to use database with integer IDs, and I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.