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 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
  • 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. 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

Ask A Question

Stats

  • Questions 68k
  • Answers 68k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer This contains a typo: <link rel='stylsheet' type='text/css' href='manage.css' /> Change… May 11, 2026 at 12:10 pm
  • added an answer Most of the APIs used to create, synchronize and monitor… May 11, 2026 at 12:10 pm
  • added an answer A simple repeater used for paging where a few page… May 11, 2026 at 12:10 pm

Related Questions

I have a small problem with a script. I want to have a default
I have a small problem with how should i think a... problem. I want
I have a small problem with interfaces. Here it is in Pseudo code :
SQL to find duplicate entries (within a group) I have a small problem and
I have a small math problem I am trying to solve Given a number
I'm having a small problem in Java. I have an interface called Modifiable. Objects
I have a small JS function that does Ajax for me and another like
I have a small utility that I use to download an MP3 file from
I have a small local network. Only one of the machines is available to
I have a small VB.NET application that I'm working on using the full version

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.