MySQL won't let me delete rows

Discussion in 'MySQL' started by kinkarso, Nov 27, 2010.

  1. #1
    Hi there,

    I am trying to clean out my database by deleting entries in certain tables. However, I am constantly getting a MySQL error message saying that I can't do so.

    Is there any way I can work around this?

    #1451 - Cannot delete or update a parent row: a foreign key constraint fails (`rayku_db`.`shout`, CONSTRAINT `shout_ibfk_1` FOREIGN KEY (`poster_id`) REFERENCES `user` (`id`))

    [​IMG]

    Thanks!
     
    kinkarso, Nov 27, 2010 IP
  2. ActiveFrost

    ActiveFrost Notable Member

    Messages:
    2,072
    Likes Received:
    63
    Best Answers:
    3
    Trophy Points:
    245
    #2
    ActiveFrost, Nov 27, 2010 IP
  3. iama_gamer

    iama_gamer Active Member

    Messages:
    404
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #3
    You are using foriegn keys. Which means some other table is dependant on the info in the table you are deleting from. You can use ON DELETE CASCADE on the child table to solve this.
     
    iama_gamer, Nov 27, 2010 IP