CREATE TEMPORARY TABLE t_p AS
SELECT DISTINCT guid_prac FROM stat_prac_2017 WHERE etat_l_2etat=0 AND etat_m_2etat=0 ;

UPDATE historia_pracy k, t_p t 
SET etat_l_2etat=NULL, etat_m_2etat=NULL 
WHERE k.guidpr=t.guid_prac;

UPDATE Pracownicy k, t_p t 
SET etat_l_2etat=NULL, etat_m_2etat=NULL 
WHERE k.guid=t.guid_prac;

UPDATE stat_prac_2017 k, t_p t 
SET etat_l_2etat=NULL, etat_m_2etat=NULL 
WHERE k.guid_prac=t.guid_prac;