SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru
    Join Date
    Mar 2006
    Posts
    701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Error Number: 1452 problem

    I have a table at mysql that has a foreign key at another table (product_code and product).
    Until yesterday all where ok but today when I try to insert values at product_code there is the error
    Error Number: 1452
    Cannot add or update a child row: a foreign key constraint fails
    is here.
    We do nothing at db, at toad once I have the cursor up this table, the free innodb:9216 kb message is here.
    What is wrong?
    Dimis

  2. #2
    SitePoint Guru
    Join Date
    Mar 2006
    Posts
    701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found it, after a mysql problem we recreate the tables and product was myisam and not innodb.
    Dimis

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,016
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    the row you are attempting to update or insert contains a value in a foreign key which does not exist in the key column of the table it references
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  4. #4
    SitePoint Evangelist
    Join Date
    Aug 2007
    Posts
    566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's because that the value in the field with a foreign key constraint that you insert have no reference into the parent table.

    It's what foreign key are doing, enforcing you to insert a value that exists.
    http://dictionary.die.net/foreign%20key


Bookmarks

Posting Permissions

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