 where emanimi != '' ;
 
 insert ignore into x_nimekujud4 (id, tunnus, v)
-select emi_id, 'sünd', left(SUBSTRING_INDEX(SUBSTRING_INDEX(                                      sünd, ';', n.n), ';', -1), 4)
+select distinct emi_id, 'sünd', left(SUBSTRING_INDEX(SUBSTRING_INDEX(                                      sünd, ';', n.n), ';', -1), 4)
 from kirjed k 
 INNER JOIN
 (select 1 n union all select 2 union all select 3 union all select 4 union all 

where sünd != '' ;

insert ignore into x_nimekujud4 (id, tunnus, v)
select emi_id, 'surm', left(SUBSTRING_INDEX(SUBSTRING_INDEX(                                      surm, ';', n.n), ';', -1), 4)
from kirjed k 
INNER JOIN
(select 1 n union all select 2 union all select 3 union all select 4 union all 

where isanimi != '' ;

insert ignore into x_nimekujud4 (id, tunnus, v)
select distinct emi_id, 'emanimi',   SUBSTRING_INDEX(SUBSTRING_INDEX(replace(replace(emanimi, '-',';'),' ',';'), ';', n.n), ';', -1)
from kirjed k 
INNER JOIN
(select 1 n union all select 2 union all select 3 union all select 4 union all 
