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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:03:46+00:00 2026-05-27T20:03:46+00:00

I have two tables named MEMBER – columns id(primary key), name, email & TOPICS

  • 0

I have two tables named

MEMBER – columns id(primary key), name, email &

TOPICS – columns id, topic_type, created_by.

I want to create a new table MEMBER_TO_TOPICS which maps member to topics, which has columns memberid(foreign key of member table id), topicid(foreign key of topic table id), created_time.
Here is the query am trying to execute .

CREATE TABLE `gsraisin`.`member_to_topics` (
`member_id` VARCHAR(50) NOT NULL,
`topic_id` VARCHAR(50) NOT NULL,
`created_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`member_id`, `topic_id`),
CONSTRAINT `FK_member_to_topics_memberid` FOREIGN KEY `FK_member_to_topics_memberid`   
(`member_id`)
REFERENCES `member` (`id`)
ON DELETE CASCADE
ON UPDATE NO ACTION,
CONSTRAINT `FK_member_to_topics_topicid` FOREIGN KEY `FK_member_to_topics_topicid` 
(`topic_id`)
REFERENCES `topics` (`id`)
ON DELETE CASCADE
ON UPDATE NO ACTION
)
ENGINE = InnoDB;

But getting the following error while executing – MYSQL Error Number 1005 can’t Create table member_to_topics (errno:121)

  • 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-27T20:03:47+00:00Added an answer on May 27, 2026 at 8:03 pm

    I tried this on my local machine and it worked fine.

    mysql> show create table member;
    +--------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | Table  | Create Table                                                                                                                                                                                       |
    +--------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | member | CREATE TABLE `member` (
      `id` varchar(50) NOT NULL DEFAULT '',
      `name` varchar(50) DEFAULT NULL,
      `email` varchar(50) DEFAULT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
    +--------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    1 row in set (0.00 sec)
    
    
    mysql> show create table topics;
    +--------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | Table  | Create Table                                                                                                                                                                                                  |
    +--------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | topics | CREATE TABLE `topics` (
      `id` varchar(50) NOT NULL DEFAULT '',
      `topic_type` varchar(50) DEFAULT NULL,
      `created_by` varchar(50) DEFAULT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
    +--------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    1 row in set (0.00 sec)
    
    mysql> show create table member_to_topics;
    +------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | Table            | Create Table                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
    +------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | member_to_topics | CREATE TABLE `member_to_topics` (
      `member_id` varchar(50) NOT NULL,
      `topic_id` varchar(50) NOT NULL,
      `created_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      PRIMARY KEY (`member_id`,`topic_id`),
      KEY `FK_member_to_topics_topicid` (`topic_id`),
      CONSTRAINT `FK_member_to_topics_memberid` FOREIGN KEY (`member_id`) REFERENCES `member` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
      CONSTRAINT `FK_member_to_topics_topicid` FOREIGN KEY (`topic_id`) REFERENCES `topics` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1 |
    +------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    1 row in set (0.00 sec)
    

    Error code 121 is for Duplicate Key.

    [matthewh@kookaburra ~]$ perror 121
    OS error code 121:  Remote I/O error
    MySQL error code 121: Duplicate key on write or update
    

    I suspect you may have a duplicated constraint name perhaps?

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

Sidebar

Related Questions

I have two tables named foo and bar , hypothetically speaking. foo has columns
I have two tables, both named as say, Employee in two different schema HR
I have two tables: Client(id,name,...) Purchase(id,item,date,client_id,...) They have their respective Model, with their validations.
I have two tables: Contact (id,name) Link (id, contact_id, source_id) I have the following
I have two tables with the same structure: id name 1 Merry 2 Mike
I have two tables: Companies: (id, name) Workers: (id, name, country) I would like
I have two tables, name and address. I would like to list the last_name
I have two tables in a MySql DB: items id (char) name (varchar) description
I have two tables --> Variables (id, name) and Variable_Entries (id, var_id, value). I
I have two tables, named t_master and t_detail. The data in the t_detail table

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.