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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:37:24+00:00 2026-06-03T23:37:24+00:00

I am using MySQL, I don’t have a good way to do this. I

  • 0

I am using MySQL, I don’t have a good way to do this.

I have a table with a position field, which I need to keep track having values from 1 to 10,000.

Let’s say I insert a record in the middle at 5000th position. So position 5000 to 10,000 need to be updated to the new position; old 5000 become 5001, 5002 becomes 5003…

Is there a good way to implement this without affecting so many records, when 1 single position is added?

Adding from the position 1st is the worst.

  • 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-06-03T23:37:26+00:00Added an answer on June 3, 2026 at 11:37 pm

    I’d rethink the database design. If you’re going to be limited to on the order of 10K records then it’s not too bad, but if this is going to increase without bound then you’ll want to do something else. I’m not sure what you are doing but if you want a simple ordering (assuming you’re not doing a lot of traversal) then you can have a prev_id and next_id column to indicate sibling relationships. Here’s the answer to your questions though:

    update some_table 
    set some_position = some_position + 1
    where some_position > 5000 and some_position < 10000
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using MySQL for 2 years now, yet I still don't know
Note: Using MySQL 4.0, which means no subqueries (at present). I have 2 tables:
using mysql and php, I have two tables, I'm french so the table names
I'm using MySQL, but I think this is a basic SQL question. I don't
I have a part of webpage that is dynamically generated using MySQL queries: <table
Using MySQL I need to have a list (possibly long list) of x,y coordinates.
Using MySQL, when I have a table with (for example) three keys (one primary,
I am working in php in which i am using mysql. This is my
I need to have two databases placed on the same mysql server synchronised. This
I am using MySQL 5.0. I have table with following structure and data. CREATE

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.