0

I have a table called member where I have a column called handicap. Player Handicap is a FOREIGN KEY in table called stableford.

Member Table:

 Name              |          Handicap

 Joe Bloggs        |             18

Stableford Table:

  Player_name    |     Player Handicap    |   Score   |   Handicap Change
    Joe Bloggs   |            18          |     38    |         17

I now want to update the Player Handicap with the Handicap Change value(17) but I get an error - cannot update a child row. Player Handicap is a FOREIGN KEY in the Stableford table. It REFERENCES member(handicap). Please help, thanks.

hankey39
  • 349
  • 2
  • 5
  • 19
  • if you want to change Foreign Key field of table, it's not accept another value until the reference field is valid. try set ON UPDATE & ON DELETE role for field. – Reza-S4 Apr 13 '15 at 17:10
  • Tried update stableford set ON UPDATE Player Handicap = handicapChange. Still not working. In my stableford table I added ON UPDATE CASCADE to the FOREIGN KEY player handicap. Dont know if that is right or not. – hankey39 Apr 13 '15 at 17:58
  • ON UPDATE CASCADE should do what you want, though it begs the question of why you have Handicap stored on the Member table at all. – xathien Apr 13 '15 at 18:05
  • I need the members handicap to be used in a session. So I am trying the following: update stableford set ON UPDATE player_handicap = handicapChange, but still getting error; – hankey39 Apr 13 '15 at 18:16
  • check this : http://stackoverflow.com/questions/1481476/when-to-use-on-update-cascade and http://dba.stackexchange.com/questions/74627/difference-between-on-delete-cascade-on-update-cascade-in-mysql – Reza-S4 Apr 13 '15 at 18:29

0 Answers0