select concat('insert into EXTERNAL_PERSON values(null, ',
	p2.ID_INTERNAL,
	',',
	WORK_LOCATION.ID_INTERNAL,
	', 1);') as ""
from PUBLICATION_AUTHOR
	inner join AUTHOR on AUTHOR.ID_INTERNAL = PUBLICATION_AUTHOR.KEY_AUTHOR
	left join PERSON p1 on p1.ID_INTERNAL = AUTHOR.KEY_PERSON
	inner join PERSON p2 on p2.USERNAME like concat('author', AUTHOR.ID_INTERNAL)
	inner join WORK_LOCATION on WORK_LOCATION.NAME = AUTHOR.ORGANISATION
where p1.ID_INTERNAL is null
group by AUTHOR.ID_INTERNAL;
