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

  • Home
  • SEARCH
  • 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'm looking at parsing a delimited string, something on the order of a,b,c But
I have a large database of resumes (CV), and a certain table skills grouping
What code or script am I looking for in order to sticky a menu
I am looking for a solution\software that I can use in order to render
I'm looking for high-resolution timing code for iPhone, in order to do some performance
I know that Job.all returns an array of all jobs. But, what would be
I'm looking for a profiler in order to find the bottleneck in my C++
I've been looking at ways people test their apps in order decide where to
I'm looking for a container that keeps all its items in order. I looked
Looking for feedback on : http://code.google.com/p/google-perftools/wiki/GooglePerformanceTools

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.