How will you keep a specific country on top in a drop down list?

Have another int column in the country table called precedence.

Assign United States a precedence greater than 1 and leave all other countries at 0.

Your SQL would then look like:

select Name from countries
order by precedence desc, name asc

This will allow you to scale this later if need be.


Generally something like:

SELECT 
    CountryName 

from tableOfCountries 

ORDER by 
    (case when CountryName = 'US' then 0 
     else 1 end) asc, CountryName asc

I certainly wouldn't abuse ID that way if I could avoid it.

One could give priorities to countries and then:

select isoCode, name from countries order by priority desc, name

Alternatively, why have it at the top? I'd suggest changing the logic so that they remained in alphabetical order, but US was the default selection until changed.

Tags:

C#

.Net

Oracle