เพิ่มเติมให้อีกนิดครับ จึงจะพอใช้ได้ แต่มันเข้าทีละเรคคอร์ด
INSERT ignore INTO person_address (person_address_id,person_id,addrpart,moopart,road,chwpart,amppart,tmbpart)
select (select max(person_address_id)+1 from person_address),p.person_id,pt.addrpart,pt.moopart,pt.road,pt.chwpart,pt.amppart,pt.tmbpart
from patient pt ,person p
where pt.cid =p.cid and p.person_id not in(SELECT person_id FROM person_address)
and p.village_id=1
and p.cid is not null
and (p.cid <> '1111111111111' and p.cid <> '2222222222222' and p.cid <> '3333333333333' and
p.cid <> '4444444444444' and p.cid <> '5555555555555' and p.cid <> '6666666666666' and
p.cid <> '7777777777777' and p.cid <> '8888888888888' and p.cid <> '9999999999999' and
p.cid <> '0000000000000')