table1
id:naam:doemee
1,peter,1
2,jan,1
3,gerard,1
4,kees,0
table2
id_user:naam:
1, peter,1
3,gerard,1
select * from table1 a, table2 b WHERE NOT EXISTS (b.id_user) and a.doemee = '1'
select * from table1 a, table2 b WHERE NOT EXISTS (b.id_user) and a.doemee = '1'
insert into table2 (id_user,naam)
select id,naam
from table1
where doemee=1
and not exists (select 1 from table2 where id_user=id)
insert into table2 (id_user, naam) select id,naam from table1 as test1 where doemee ='1' and not exists (select * from table2 as test2 where test1.id = test2.id_user )