UPDATE _import_optical_groups 
   SET tetelek = (SELECT count(*) FROM _import_optical_items WHERE _import_optical_items.fajta2 = _import_optical_groups.kod)
 WHERE fajta_kod = 2;
   
UPDATE _import_optical_groups 
   SET tetelek = (SELECT count(*) FROM _import_optical_items WHERE _import_optical_items.fajta3 = _import_optical_groups.kod) 
 WHERE fajta_kod = 3;
   
UPDATE _import_optical_groups 
   SET tetelek = (SELECT count(*) FROM _import_optical_items WHERE _import_optical_items.fajta4 = _import_optical_groups.kod) 
 WHERE fajta_kod = 4;
   
UPDATE _import_optical_groups 
   SET tetelek = (SELECT count(*) FROM _import_optical_items WHERE _import_optical_items.fajta5 = _import_optical_groups.kod) 
 WHERE fajta_kod = 5; 
   
UPDATE _import_optical_groups 
   SET tetelek = (SELECT count(*) FROM _import_optical_items WHERE _import_optical_items.fajta6 = _import_optical_groups.kod) 
 WHERE fajta_kod = 6;

UPDATE _import_optical_groups 
   SET torolve = 0; 

UPDATE _import_optical_groups 
   SET torolve = 1 WHERE (kod > 9000001) AND (tetelek = 0);