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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:00:13+00:00 2026-05-15T22:00:13+00:00

I have a table of items that need to be displayed in a certain

  • 0

I have a table of items that need to be displayed in a certain order, but that order can be changed. Items can be added at the beginning, end, or in the middle, and items can be rearranged. How can I set up the table to keep track of that order in such a way that it’s easy to modify but the list can also be fetched in order with a single query?

For example, I could have a “NEXT_ID” column to do it linked list-style, but then how would I run a SELECT query to get the rows in order of the NEXT_ID chain?

Apologies in advance for the super-obvious solution I’m probably missing.

  • 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-15T22:00:13+00:00Added an answer on May 15, 2026 at 10:00 pm

    I have this problem often, and I solved it with a simple solution : an extra column called Sort Order (or DisplayOrder, whatever floats your boat really) . This allows me the flexibility to use auto-generated, auto-incremented ID column and have a special pre-defined sort.

    In my case, I need them to come out of the database with an alphabetical order except that some items like “Other” and “N/A” are always last.

    ProdID ProdText SortOrder
    2      "Anchovies"    1
    3      "Rivet"        2
    4      "N/A"          4
    5      "Other"        3
    
    SELECT ProdID, ProdText ORDER BY Sort Order
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table full of items that each have a unique ItemID .
let's say that I have a table called Items (ID int, Done int, Total
I have a following table using MVC that shows number of items the user
I have a recordset loop that creates a table, and every 9 items it
I have table of data that is sorted as follows: Item | Sample |
I have a table that I keep track of fees for a specific item.
I have a table called 'MyTable' that looks like: ID | Item | Type
I have a question: I have two MSSQL tables, items and states, that are
I have a bill of materials table that is set up like this: item
I have 3 tables, - Section table that defines some general item sections. -

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.