MySQL Forums
Forum List  »  Newbie

Re: Wrong player is edited
Posted by: Peter Brawley
Date: June 04, 2019 11:36AM

> If a player in a team has the same "Rugnummer" as the player that is being inserted,
> the player's "Rugnummer" that is being inserted should be changed.

As you saw, On Duplicate Key ... will update the row with the existing `rugrunner` value. You need a Trigger that says something like ...

...
if !is_null( select rugrunner from speiers where rugrnunner=new.rugrunner ) then
  set new.rugrunner = ( select 1 + max(rugrunner) from speiers );
end if;

And: speier_id is the Primary Key, so the Unique Key on speier_id  is perfectly redundant, lose it.

Options: ReplyQuote


Subject
Written By
Posted
June 03, 2019 03:09AM
June 04, 2019 12:34AM
Re: Wrong player is edited
June 04, 2019 11:36AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.