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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:13:49+00:00 2026-06-17T12:13:49+00:00

Situation I want to convert certain status fields within my PHP/MySQL application to handle

  • 0

Situation

I want to convert certain status fields within my PHP/MySQL application to handle more than one at any time. Take below what is currently an ENUM field as an example:

STATUS_ACTIVE
STATUS_FROZEN
STATUS_PENDING
STATUS_FLAGGED
STATUS_DELETED

Currently, it will only support one at a time. However by converting the set in to binary, I end up up with a set of strings.

1     STATUS_ACTIVE
10    STATUS_FROZEN
100   STATUS_PENDING
1000  STATUS_FLAGGED
10000 STATUS_DELETED

Now, when it comes to filtering PHP wise, I have no issues. However, this introduces a large (and unnecessary) overhead. It is very possible an entry could end up as

10010
01110
etc.

Question

I’ve done some digging around and the best piece of information I have found was actually on stackoverflow (ironically) here. Can someone please explain the actual syntax used there or point me to a correct MySQL manual page.

It’s not very clear just how one would hypothetically go about these situations:

Changing only the third bit
Searching for 1 on only the fourth bit
Updating two binary flags at the same time

It would be really appreciated to have even a knock in the right direction, thanks for reading.

Edit: I have figured out most of the syntax. My question now: is it possible to change more than one bit at a time without having to redefine the whole thing?

I.e

100 -> 1011
1 -> 101
  • 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-17T12:13:51+00:00Added an answer on June 17, 2026 at 12:13 pm

    Answering your updated question. For example we need 3 and 5 bits.

    If you need to SET 3 and 5 bits you should OR your field with 10100

    UPDATE table SET options = options | ((1 << 2) | (1 << 4))
    

    If you need to CLEAR 3 and 5 bits you should AND your field with 11101011 = NOT(10100)

    UPDATE table SET options = options & (~((1 << 2) | (1 << 4)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a situation where I want certain code to be executed no matter
I have a situation where I want to convert some XAML to an image,
I have a situation were I want to convert a string into an SortedMap<String,SortedMap<String,Object>>
The Situation: I'm using ffmpeg (via php) to convert video files. I configured my
I have a situation where I want to convert a RTF document to image
I came across a situation where i want to sort the mysql query result
Situation: I want to provide a website service where users can enter some data
I have a sort of unique situation....I want to populate a ModelChoiceField based of
So the situation is: I want to optimize my code some for doing counting
I have a situation where I want a bash script to replace an entire

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.