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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:51:22+00:00 2026-05-12T10:51:22+00:00

i have a stack of messages in database table. i want to send these

  • 0

i have a stack of messages in database table.
i want to send these messages by their priority so i added “Priority” column to “messages” table.

but what if i want to insert “cram” message between two messages and give the previous priority to this new message?.

Should i update all messages priority under this message.

So please give me the perfect design for my database table to support priority update.

  • 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-12T10:51:23+00:00Added an answer on May 12, 2026 at 10:51 am

    Use a float column for Priority rather than an int.

    Then, to insert a message between two others, assign the average of the two messages’ Priority values as the new message’s Priority. (E.g., to insert a cram message between a messages with Priority 2 and 3, assign it a Priority of 2.5).

    By doing this, you don’t have to update any other messages’ priority, and you can continue to average/insert between those, etc. until you bump up against the decimal accuracy limits of a float (which will take awhile, especially if the raw Priority values tend to be small).

    Or, add another column after Priority in the ORDER BY. In the simplest case, use bit column called “ShowAfter” with a default value of 0. When you insert a cram message, give it the same Priority as the message you want to see it after, but a [ShowAfter] value of 1.

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

Sidebar

Related Questions

I have a stack which contains some integer data. I want to find out
I have a small problem when I get old messages from my database. I
I have a BizTalk 2010 solution that polls a database table, retrieves unprocessed records,
I have a database wherein per day a table is created to log process
How to insert data into table in sqlite iPhone? I am trying following, but
I have a database schema like this: My database schema: https://i.stack.imgur.com/vFKRk.png To explain the
I have been stuck for a long time on this simple but obtuse message
I have stack panel with custom controls in it. I attach standard MouseDragElementBehavior to
I have stack panel with custom controls in it. User can add or remove
I have a stack of images, absolutely positioned on the same place and I

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.