CREATE TRIGGER mediaitems_update_FSK_german_all AFTER UPDATE ON MediaItems
WHEN old.OfficialRating <> new.OfficialRating
or old.CustomRating <> new.CustomRating
BEGIN
update MediaItems SET OfficialRating = 'FSK 0' WHERE OfficialRating like '%-0' or OfficialRating in ('G','TV-G','TV-Y');
update MediaItems SET OfficialRating = 'FSK 6' WHERE OfficialRating like '%-6' or OfficialRating in ('PG','TV-Y7','TV-Y7-FV','TV-PG');
update MediaItems SET OfficialRating = 'FSK 12' WHERE OfficialRating like '%-12' or OfficialRating in ('PG-13');
update MediaItems SET OfficialRating = 'FSK 16' WHERE OfficialRating like '%-16' or OfficialRating in ('TV-14');
update MediaItems SET OfficialRating = 'FSK 18' WHERE OfficialRating like '%-18' or OfficialRating in ('NC-17','R','TV-MA');
update MediaItems SET CustomRating = 'FSK 0' WHERE CustomRating like '%-0';
update MediaItems SET CustomRating = 'FSK 6' WHERE CustomRating like '%-6';
update MediaItems SET CustomRating = 'FSK 12' WHERE CustomRating like '%-12';
update MediaItems SET CustomRating = 'FSK 16' WHERE CustomRating like '%-16';
update MediaItems SET CustomRating = 'FSK 18' WHERE CustomRating like '%-18';
END