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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:26:26+00:00 2026-06-13T07:26:26+00:00

So I am in the process of attempting to create a basic user system

  • 0

So I am in the process of attempting to create a basic user system and within this system I want users to be able to have multiple roles.

Say for example I have the roles as follows: Administrator, Events Organiser, Donator

What is the best way to assign these multiple roles to a user and then check if they have any of these roles for showing certain permissions.

If it was only one role per person then it wouldn’t be a problem as I’d just assign say Administrator = 10, Organiser = 5 and Donator = 1 and then do an if statement to check if the MySQL data is equal to any of those three numbers.

I can’t imagine there is a way to add a MySQL Field and fill it with say “Administrator,Donator” and therefore that user would have both of those roles?

Is it just a case of I would need to create 3 separate fields and put a 0 or a 1 in those fields and check each one separately?

  • 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-13T07:26:27+00:00Added an answer on June 13, 2026 at 7:26 am

    Use multiple tables and join them:

    User
    --------------
    id    name
     1    test
    
    Role
    --------------
    id    name
     1    Donator
     2    Organizer
     3    Administrator
    
    User_Role
    --------------
    id    user_id    role_id
     1    1          1
     2    1          3
    
    
    SELECT * FROM User u 
        LEFT JOIN User_Role ur ON u.id = ur.user_id
        LEFT JOIN Role r ON ur.role_id = r.id
    WHERE r.name = "Administrator";
    

    The query is easier if you know you only have 3 roles and they are easy to remember.

    SELECT * FROM User u LEFT JOIN User_Role ur ON u.id = ur.user_id WHERE ur.role_id = 3;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to create a process that verifies data within a database and notifies
I am attempting to create a singleton service that is used to process incoming
I'm attempting to create a new project in TFS 2008. The process errors out
I am attempting to create my first OS-level GUI using wxPython. I have the
I want to programmatically determine if the current user (or process) has access to
I am attempting to create a VBscript that will kill a Windows process that
I am attempting to create a simple iOS application, mostly for the learning process,
All, I'm currently in the process of attempting to create a repeatable process for
I've been attempting to create a new process under the context of a specific
I am attempting to write a MarkupExtension to support the process of instantiating custom

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.