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

  • Home
  • SEARCH
  • 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 6560951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:31:38+00:00 2026-05-25T13:31:38+00:00

I have a table set up on a mysql database called access with three

  • 0

I have a table set up on a mysql database called “access” with three columns called:

rights_id, (PRIMARY KEY)

username,

name,

In the rights_id column the user can only input 3 different values (“1″,”2”, or “3”) 1 means resource, 2 means manager, and 3 means administrator. my problem occurs when there are more than one row with the same rights_id (ie: more than one administrator).It displays an error that tells me i can’t have a duplicate entry for the PRIMARY KEY… i was wondering if there was a way to supress this error and allow me to do this? im using vb.net to interact with my MYSQL database running on a Windows 7 OS. Thanks!

  • 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-25T13:31:39+00:00Added an answer on May 25, 2026 at 1:31 pm

    I’m not sure what “name” means in that table. If it’s safe for me to ignore it . . .

    If each username can have only one “rights_id”, then the primary key should be username. If each username can have more than one “rights_id”–if user Catcall can have rights_id 1 and 2 at the same time–then your primary key should be the pair of columns (rights_id, username).

    Since MySQL doesn’t enforce CHECK constraints, you should have a separate table of rights id numbers, containing three rows.

    create table rights_ids (
      rights_id integer primary key
    );
    insert into rights_ids values (1);
    insert into rights_ids values (2);
    insert into rights_ids values (3);
    

    Then you can set a foreign key constraint that will prevent any numbers besides those three from appearing in the table named “access”. Something like

    alter table access
    add constraint foreign key (rights_id) references rights_ids (rights_id);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three tables set up in a MySQL database called event, status and
So. I have a table of data, in a MySQL database, eg: Artist Name
I have a mysql database table called POST . One of the fields is
I have a MySQL database/table set up and a .php file online that inserts
In my MySQL database, I have a table with structure username - varchar insert_time
I have a table in my MySQL database called 'children'. In that table is
I have a table where one of the left column shrinks when I set
Situation: In my database I have a table called ' artists ' and '
Heres my problem. I have a mysql table called quotes. In one of the
I have in my MySQL database these two tables: CREATE TABLE IF NOT EXISTS

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.