SET NAMES cp1250;
 UPDATE `slowniki_pierwotne` sp, `_db_globals` dg
SET
	sp.ParamExtra = REPLACE(REPLACE(
		CONCAT_WS(';',
		NULLIF(NULLIF(REPLACE(REPLACE(sp.ParamExtra, 'InProgress', ''), 'Completed', ''), ';'), ''),
		IF(sp.Value IN (2,4,8), 'Completed', 
		IF(sp.Value IN (0), 'InProgress', 
		IF(sp.Value IN (33), IF(dg.Value = 'COMEX', 'Completed', 'InProgress;Completed'),
		'InProgress;Completed')))
		),
		';;;', ';'), ';;', ';')
WHERE 
	sp.Slownik_GUID = 'zamwstatus' 
	AND dg.Key = 'Owner'
;
