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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:44:58+00:00 2026-05-28T06:44:58+00:00

I need to save multiple options into a single field so that I didn’t

  • 0

I need to save multiple options into a single field so that I didn’t have to create a column for each option. The options that can be selected will increase over time so using columns will probably not be the best way to go with this… One too many options can be selected at a time and save to the database.

So I have come up with the following solution and was wondering if there was a better way to do this and also if anyone can see any issues with it. I have done testing and it seems to work fine for the variations I selected.

Method:
Assign all the options a unique prime number, let the user select the options he wants, multiply the selected option’s corresponding prime number and save the resultant value in the field.
When checking if the option was selected:
If the number saved is divisible by the prime number without a remained, that prime number’s corresponding option was selected by the user.
Eg:

  • Monday 2, Tuesday 3, Wednesday 5, Thursday 7, Friday 11,
    Saturday 13, Sunday 17

Selection:
Monday, Friday, Sunday
2 * 11 * 17 = 374

**Monday** = 374/2=187,  (Or 374 % 2 = 0)
Tuesday = 374/3=124.6666666666667, 
Wednesday = 374/5=74.8,  
Thursday = 374/7=53.42857142857143, 
**Friday** = 374/11=34,  
Saturday = 374/13=28.76923076923077, 
**Sunday** = 374/17=22
  • 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-28T06:44:59+00:00Added an answer on May 28, 2026 at 6:44 am

    I think you can use de bitwise permissions pattern. Basically you store each option as a power of 2. In this way you can have all the posible combinations in a single integer field. Just google Bitwise persmission to implement the solution

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

Sidebar

Related Questions

I have a report that I need to run multiple times and save as
I have a table that contains multiple rows. Each row contains 5 columns (or
I have a big zipfile that I need to split in multiple zip files.
I'm making an app where I need to save the text in multiple views
I have multiple variables in a shell script; i was trying to save some
If I need to update or insert into multiple tables with one action, example
I have a form that contains multiple partners that share a pool. The partners
We have a string field which can contain XML or plain text. The XML
I would like to have a model in Django that has multiple pictures associated
I need to save a user's login information in encrypted form for this application

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.