SELECT
person.pcucodeperson,
person.pid,
person.idcard,
person.hosmain,
person.hossub,
person.typelive,
person.rightcode,
person.mumoi
from person inner join house on person.pcucodeperson = house.pcucode and person.hcode = house.hcode
where concat(person.pid,person.pcucodeperson)not in (select concat(persondeath.pid,persondeath.pcucodeperson)
from persondeath where deaddate<=curdate() or deaddate is not null)
and person.typelive in ('1','3') and person.hossub != person.pcucodeperson;