Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2012
    Posts
    1

    Question Unanswered: Create foreign key

    Hi,

    I having problem create foreign key. This is my table.

    Table info
    ndp PRIMARY KEY,
    name,
    address,
    D.O.B,
    P.O.B,
    contact no

    Table subject
    ndp
    subject,
    year_take,
    year_finish

    From table subject i want to create FK_subject and column is ndp. This is using InnoDB. All in varchar. But i got this kind or error:
    Code:
    SQL Error: Cannot add or update a child row: a foreign key constraint fails (`system`.<result 2 when explaining filename '#sql-a00_f'>, CONSTRAINT `#sql-a00_f_ibfk_1` FOREIGN KEY (`ndp`) REFERENCES `subject` (`ndp`))
    Please assist me.

    Thanks/.

  2. #2
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    Can you provide the create statements?
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •