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 8847237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:08:58+00:00 2026-06-14T12:08:58+00:00

I have the table ‘category’ with two columns: ‘id’ and ‘name’. I Want to

  • 0

I have the table ‘category’ with two columns: ‘id’ and ‘name’.

I Want to display the names and order the table by alphabet, but if the name “other” is present, i want to set it to be the last row.

Is there a way to achieve this without creating another column that marks the position?

ORDER BY name DESC { something to set name = "other" to the end }

THANKS!

  • 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-06-14T12:08:59+00:00Added an answer on June 14, 2026 at 12:08 pm

    Using a CASE, you can apply ordering conditionally in the ORDER BY. Rows where name <> 'other' are conditionally assigned a 0 which sorts ahead of those matching other which are assigned a 1. Then it is sub-ordered by name.

    ORDER BY
      CASE WHEN name <> 'other' THEN 0 ELSE 1 END,
      name ASC
    

    You use name DESC in your example, but your description implies you want it sorted in ascending alphabetical order. If that is incorrect and you do want it descending, use name DESC instead.

    Note that for MySQL, the boolean expression (name = 'other') will evaluate to a 0 or 1. So this can be simplified to omit the CASE:

    ORDER BY
      /* name <> 'other' returns 0 */
      (name = 'other'),
      name ASC
    

    This is not portable to any RDBMS though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table with two columns (varchar from, varchar to). This table represents connections
I have table Players with columns: ID Name Points What is most efficient way
I have table with 5 columns ------------------------------------------------------ |_id(mongo default)| link | name| street|zip |
I have table with two columns: price and constant . I would like to
I have table in which I am inserting rows for employee but next time
I have table in my database which has fields of ID,NAME,CONTEXT. I am showing
I have table with data 1/1 to 1/20 in one column. I want the
I have table pro like this : id category details 1 f weqweq 2
I have table Races with the rows ID , Name and TotalCP . I
I have Table and I want to put it in the middle of the

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.