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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:41:06+00:00 2026-05-11T06:41:06+00:00

I have a small problem. I’m populating a select tag with results from a

  • 0

I have a small problem. I’m populating a select tag with results from a SQL database. What I would like to have is the last one added as the top entry and the rest sorted alphabetically.

So it would return:

*----------*-------------* developerID|developerName *----------*-------------* | 40       | ZZZ Dev     | | 39       | A Dev       | | 38       | Be New Dev  | *----------*-------------* 

Currently it just selects all the entries in descending order:

'SELECT developerName, developerID FROM developer ORDER BY developerID DESC' 

Which is fine, but not as usable as I would like.

Is what I want possible using pure MySQL?

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-11T06:41:06+00:00Added an answer on May 11, 2026 at 6:41 am

    Assuming the column defining when the developer was added is developerAdded (a timestamp of some sort):

    SELECT developerName, developerID, 1 AS ordering     FROM developer     WHERE developerAdded =  (SELECT MAX(developerAdded)                                 FROM developer) UNION SELECT developerName, developerID, 2 AS ordering     FROM developer     WHERE developerAdded != (SELECT MAX(developerAdded)                                 FROM developer) ORDER BY ordering, developername; 

    If there’s some other magic way to determine the most recently added developer (e.g. maximum developerID), adjust the sub-queries accordingly.

    Note that this query works OK even if several developers satisfy the ‘most recently added’ criterion; they appear in alphabetic order before the developers who’ve been around longer.


    Since the most recently added developer has the maximum developerID, the revised query should be:

    SELECT developerName, developerID, 1 AS ordering     FROM developer     WHERE developerID =  (SELECT MAX(developerID) FROM developer) UNION SELECT developerName, developerID, 2 AS ordering     FROM developer     WHERE developerID != (SELECT MAX(developerID) FROM developer) ORDER BY ordering, developername; 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to resize the topmost windows. I have small problem in the
I would like to write to a text file, but I have small problem.
I have a small problem when I get old messages from my database. I
I have a small problem, I would like a div to be displayed when
have small problem, and would very much appreciate help :) I should convert byte
I have a small problem, I want to load data from a PHP file
i have small problem i.e. their is one celltable with lot of data it
I have a small problem with OrmLite on Android. When I increment the database
I have a small problem here. I want to list my files from a
I have one small problem regarding MPMoviePlayerController, i have a link that play movie

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.