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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:13:29+00:00 2026-06-13T01:13:29+00:00

I have a mysql table where user permissions are stored as a bitmask: |user

  • 0

I have a mysql table where user permissions are stored as a bitmask:

|user   | permissions |
| Admin | 31          |
| User  | 13          |

           16 8  4  2  1
Admin ->   1  1  1  1  1  -> 16 + 8 + 4 + 2 + 1 -> 31
User  ->   0  1  1  0  1  ->  8 + 4 + 1 -> 13

Now I want to add a permission for every user with an sql query.
Let’s say I want to add the permission 16 for everyone without modifying another bit.

 UPDATE users SET permission = ????

How do I do this?

  • 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-13T01:13:30+00:00Added an answer on June 13, 2026 at 1:13 am

    To add permission 16, you just say

    UPDATE users SET permission = permission | 16;
    

    The bitwise OR operator will turn bits on. To turn them off, use a AND operation with the complement of the bit you want off:

    UPDATE users SET permission = permission & ~16
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MYSQL-Table which stores scores. Every time a user improves a new
I have a table generated by PHP/mysql, I want a user to click the
I am using mysql and have a table (Log_Table) storing user login dates, a
I have a working PHP server. Now I want to use databases (MySQL or
I have a directory table in a MySQL database that contains user ID's, user
What is the best practice to manage user permissions with PHP/MySQL? What I have
I have mssql2008 r2 sql server The problem: User has some column permissions on
I want to find the users(userid) from a permissions table who have all of
I have a table in mysql: CREATE TABLE user (id INT, name VARCHAR(250)); I
I have a MySQL table with approximately 3000 rows per user. One of the

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.