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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T23:55:53+00:00 2026-05-11T23:55:53+00:00

I would like to enable users of my application to define a number of

  • 0

I would like to enable users of my application to define a number of (say) email addresses. Then I would like to give them the ability to rearrange these addresses, so the primary address is on top, secondary next, etc.

Let’s suppose I have a UserEmailAddresses table in a database that links a user (UserId) and an email address (EmailAddressId).

1) What data type (int, float, etc) should I use for the field that will hold the sequence in which these email addresses will be sorted by?

2) What query would be efficient at changing these sequence numbers when the user rearranges their positions? Must it modify multiple records?

(I’m using C# and Linq, but psuedo-code welcome).

  • 1 1 Answer
  • 2 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-11T23:55:54+00:00Added an answer on May 11, 2026 at 11:55 pm

    You will need to add an integer field that stores the sort order of the email addresses.

    As new email addresses are added they get assigned the next sort order id. If an address needs to be sorted above an existing address I would use an update statement to update all email addresses with sort order ids greater than the desired sort order index then update the reordered email address to have the desired sort order index.

    Table Schema
    -----------------------
    EmailID INT primary Key //Auto increment
    EmailAddress Varchar(N)
    SortOrderIdx INT //This would control your display order
    UserID INT //This would be the owner of this particular email list
    
    Email Create Statement
    -----------------------
    SELECT @NewSortOrdrIdx = MAX(SortOrderIdx)+1
    FROM EmailTable 
    WHERE UserId = @UserID
    
    INSERT INTO EmailTable (EmailAddress, SortOrderIdx, UserID)
    VALUES (@EmailAddress, @NewSortOrdrIdx, @UserID)
    
    Email Reorder Statement
    -----------------------
    UPDATE EmailTable
    SET SortOrderIdx = SortOrderIdx + 1
    WHERE SortOrderIdx >= @desired_Sort_Order_Idx AND UserID = @UserID
    
    UPDATE EmailTable
    SET SortOrderIdx = @desired_Sort_Order_Idx
    WHERE EmailID = @resorted_Email_ID AND UserID = @UserID
    
    Email Select Statement
    -----------------------
    SELECT EmailAddress 
    FROM EmailTable
    WHERE UserID = @UserID
    ORDER BY SortOrderIdx ASC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an MVC3 application and I would like to give the users the
I would like to enable users of my we application to be able to
Ok, let's say that I have a button and I would like to enable/disable
I'm creating an image editing application for iphone. i would like to enable the
I would like to enable users to create their own templates in my asp.net
I have an application which I would like to enable push notifications on. I
I currently have an iOS application for which I would like to enable iCloud
I would like to enable SOAP on my PHP5/Centos/Apache server. I have full access
I have a UITextField that I would like to enable auto completion on by:
I have a WPF ListBox that I would like to Enable multiple selection in

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.