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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:54:45+00:00 2026-05-23T13:54:45+00:00

Scenario : I have say 4 check boxes and users can select those checkboxes

  • 0

Scenario :
I have say 4 check boxes and users can select those checkboxes in any combination(they also have the power to not select even a single check box). I have to store these 4 options to a single column. I think the best option is to store using binary representation

option1 has the constant value 1 
option2 has the constant value 2
option3 has the constant value 4
option4 has the constant value 8

So if the customer selects option2 and option4, then the value that is stored in the DB will be 2 + 8 ie: 10, if customer selects option1, option4 and option8 the value will be 1 + 4 + 8 which is 13.

Also when I query from mysql I can use

Select * from option_table where (option & 4)=4;

if I want to retrieve rows where option3 is selected.

But for some reason I cannot use this approach, or just say I need to know what’s the next best option to store these multiple values in a single column ?

  • 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-23T13:54:46+00:00Added an answer on May 23, 2026 at 1:54 pm

    An alternative could be to multiply prime numbers. To select, you would select columns where the modulus of the prime number into the value of the column is 0.

    Example:

    Value 1: 2
    Value 2: 3
    Value 3: 5
    Value 4: 7

    Value 2 & 3 would be 3*5 = 15
    Values 1, 2, 3, 4 would be 2*3*5*7 = 210

    To get the rows where value 1 is on, select where value % 2 == 0

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

Sidebar

Related Questions

Say we have this scenario: Artist ==< Album ==< Track //ie, One Artist can
Scenario: Let's say I have four very similar applications (i.e. most of the functionality
Scenario: Let's say I have two tables, TableA and TableB. TableB's primary key is
Ok, i have simple scenario: have two pages: login and welcome pages. im using
Scenario: You have an ASP.Net webpage that should display the next image in a
Scenario I have two wrappers around Microsoft Office, one for 2003 and one for
Scenario: I have a text file that has pipe (as in the | character)
Scenario: I have a document I created using LaTeX (my resume in this case),
I have the following scenario I have a main form as MDI parent and
The scenario: we have a web system that automatically generates office 2003 excel files

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.