Il tuo problema è che non calcoli alcun marktwert valore per i giocatori (Spieler) che hanno più di 31 anni (geburtstag =compleanno). La tua istruzione UPDATE sta tentando di scrivere NULL nel marktwert colonna, che è definita come NOT NULL . E questo si traduce in un errore.
Soluzioni:
1) Utente ELSE nel tuo CASE istruzione e impostare un valore predefinito:
UPDATE _spieler SET marktwert = CASE
WHEN TIMESTAMPDIFF(YEAR, geburtstag, NOW()) <= 27 THEN ((w_staerke/100*70) + (w_technik/100*30))
WHEN TIMESTAMPDIFF(YEAR, geburtstag, NOW()) <= 31 THEN ((w_staerke/100*70) + (w_technik/100*30))
ELSE 0
END;
2) Consenti NULL valore per la colonna marktwert :
CREATE TABLE `_spieler` (
...
`marktwert` int(10) NULL DEFAULT '0',
...
)
3) Usa un WHERE condizione:
UPDATE _spieler SET marktwert = CASE
WHEN TIMESTAMPDIFF(YEAR, geburtstag, NOW()) <= 27 THEN ((w_staerke/100*70) + (w_technik/100*30))
WHEN TIMESTAMPDIFF(YEAR, geburtstag, NOW()) <= 31 THEN ((w_staerke/100*70) + (w_technik/100*30))
END
WHERE TIMESTAMPDIFF(YEAR, geburtstag, NOW()) <= 31;
Aggiornamento:puoi anche rimuovere il marktwert colonna e utilizzare una visualizzazione
(tabella calcolata) invece:
CREATE VIEW `_spieler_view` AS SELECT s.*,
CASE
WHEN TIMESTAMPDIFF(YEAR, geburtstag, NOW()) <= 27 THEN ((w_staerke/100*70) + (w_technik/100*30))
WHEN TIMESTAMPDIFF(YEAR, geburtstag, NOW()) <= 31 THEN ((w_staerke/100*70) + (w_technik/100*30))
END AS marktwert_calculated
from _spieler s ;
Aggiornamento 2:
Se usi MariaDB puoi anche usare Colonne virtuali (calcolate)