WHERE table_schema=DATABASE() and table_name LIKE 'hygf_%' and table_name not in ('hygf_personnel_business', 'hygf_unit_info', 'hygf_user_message');
WHERE (table_schema='amos_project' or table_schema='root') and table_name LIKE 'hygf_%' and table_name not in ('hygf_personnel_business', 'hygf_unit_info', 'hygf_user_message');
from hygf_power_station LEFT JOIN ( select peasant_household_id,initiate_status, contract_lock_id,stamp_status,status from hygf_household_contract
from hygf_power_station LEFT JOIN ( SELECT bb.peasant_household_id, initiate_status, contract_lock_id, stamp_status, status FROM (SELECT peasant_household_id,MAX(sequence_nbr) AS sequence_nbr from hygf_household_contract GROUP BY peasant_household_id ) aa LEFT JOIN hygf_household_contract bb ON aa.sequence_nbr=bb.sequence_nbr) b on b.peasant_household_id=hygf_power_station.peasant_household_id
) b on b.peasant_household_id=hygf_power_station.peasant_household_id
LEFT JOIN hygf_peasant_household on hygf_peasant_household.sequence_nbr=hygf_power_station.peasant_household_id
LEFT JOIN hygf_peasant_household on hygf_peasant_household.sequence_nbr=hygf_power_station.peasant_household_id