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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:21:31+00:00 2026-05-20T16:21:31+00:00

I feel I’ve tried everything possible on a very simple pair of create table

  • 0

I feel I’ve tried everything possible on a very simple pair of create table statements.

The types match, I tried using ENGINE = InnoDB, etc and am stumped why I’m getting the foreign key error.

I’ve been away from SQL for some time, so this is probably an easy one.

mysql> CREATE TABLE foo_ent(yyy_no VARCHAR(80),
    -> zoo VARCHAR(80),
    -> PRIMARY KEY (yyy_no));
Query OK, 0 rows affected (0.01 sec)

mysql> CREATE TABLE cat_ent(some_item INTEGER,
    -> yyy_no VARCHAR(80),
    -> apple DECIMAL(6,2),
    -> PRIMARY KEY (some_item),
    -> FOREIGN KEY (yyy_no) REFERENCES foo_ent);
ERROR 1005 (HY000): Can't create table 'test.cat_ent' (errno: 15
0)

Sorry about the poor variable names, safe to over-write company stuff.

  • 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-20T16:21:32+00:00Added an answer on May 20, 2026 at 4:21 pm

    You don’t reference to a field, only a table, which is incorrect.

    ...
    foreign key (yyy_no) references foo_ent(yyy_no)
    

    And according to your error number, the MySQL documentation also states;

    If you re-create a table that was
    dropped, it must have a definition
    that conforms to the foreign key
    constraints referencing it. It must
    have the right column names and types,
    and it must have indexes on the
    referenced keys, as stated earlier. If
    these are not satisfied, MySQL returns
    error number 1005 and refers to error
    150 in the error message.

    http://dev.mysql.com/doc/refman/5.5/en/innodb-foreign-key-constraints.html

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

Sidebar

Related Questions

I feel like this must be very simple, but for some reason I am
I feel like I am missing something very simple here, but this is the
I feel that it should be something very simple and obvious but just stuck
I feel like this is easy but I am missing something... Using jQuery, I
I feel very noobish asking this, but I can't seem to figure it out...
I feel kinda stupid, I tried to find an answer on here but couldn't
I feel like this is a really simple question, but I need help figuring
I feel that using GetEnumerator() and casting IEnumerator.Current is expensive. Any better suggestions? I'm
Feel like this should be something easy that I'm missing. I have a table
I feel like this must be simple to do but can't get it done

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.