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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:10:52+00:00 2026-05-27T05:10:52+00:00

I want the solution to be like the following table: ——————— emp lft rgt

  • 0

I want the solution to be like the following table:

---------------------
emp    lft   rgt
---------------------
Albert  1   12
Bert    2   3
Chuck   4   11
Donna   5   6
Eddie   7   8
Fred    9   10 
--------------------

I have inserted above example values manually. But I need it dynamically

If I am going to insert one more entry in this table it may placed at the top, middle or end of the table. For example, if I insert Ragu reporting to Fred, then after this process, I need the result as follows:

---------------------
emp    lft  rgt
---------------------
Albert  1   14
Bert    2   3
Chuck   4   13
Donna   5   6
Eddie   7   8
Fred    9   12 
Ragu   10   11 
--------------------

I need the reorganization of the numbers to happen dynamically using a stored procedures.

  • 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-27T05:10:53+00:00Added an answer on May 27, 2026 at 5:10 am

    Say you want to insert “Earl” 6 , 9

    Up the left Value of anyone with a from range > 6.

    UPDATE YOURTAB SET Lft = Lft + 1 where lft > 6;
    

    Then update the corresponding “Rgt” for anyone with a value greater than +6.

    UPDATE YOURTAB SET Rgt = Rgt + 1 where Rgt > 6;
    

    The Insert the new row in the correct place.

    INSERT INTO YOURTAB VALUES “Earl”,6, 9

    A simpler more scalable approach would be to INSERT the initial values as multiples
    of 100, then you can easily insert new values between the existing ranges. This would still require you to reorganize if you inserted a contiguous range of 6 new entries (150,125,112,106,103,101).

    Or even better use floating point numbers for the range values then you will never need to reorganize as the will always be a number between the existing entries.
    i.e. always a value (Lft of row after - Lft of row before) / 2

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

Sidebar

Related Questions

Like the title says, I want to have a HTML table that allows its
I have a table with values like the following Name DatePurchased QuantityPurchased A 2/3/2012
I want to have a database table that keeps data with revision history (like
I have a table that looks like the following (simplified): <table id=product_table> <tbody> <tr>
I want to display a double bordered like following image... The border has a
I'd like to find a, hopefully simple, solution to the following problem. I have
I'd like to set up the following database scenario: CREATE TABLE IF NOT EXISTS
I want to create a data-entry form like the following: Name: [ Name textbox
I have a table like the following : code ---> INTEGER name ---> CHAR
I want a solution for udnerstanding how to hold a real loop counter as

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.