
INSERT INTO `obpm2`.`tenant_users`(`id`, `authenticated_status`, `authenticated_result`, `authenticated_time`, `birthdate`, `checked_status`, `created_time`, `email`, `habit_setting`, `head_photo`, `im_identity`, `lon_lat_json`, `name`, `sex`, `stature`, `telephone`, `user_type`, `selected_credential_id`, `household_type`, `one_inch_color_white_photo`, `two_inch_color_blue_photo`, `education`, `marital_status`, `military_status`, `nation`, `native_place`, `politics_status`)
select
    id,(case when FIELD21='已认证' then 3 when FIELD23='未认证' then 0 else 2 end),
    FIELD23,LASTMODIFYTIME,null,(case when FIELD13 ='已核验' then 1 when FIELD13='未提交' then 0 else 2 end),
    IFNULL(LASTMODIFYTIME,CURRENT_TIMESTAMP),email,null as habit_setting, FIELD20 as head_photo,
    null as im_identity, FIELD25 as lon_lat_json,`NAME`,0,
    null as stature,
    LOGINNO as telephone,
    0 as userType,null as selected_credential_id,null as household_type,
    null as one_inch_color_white_photo,null as two_inch_color_blue_photo,
    null as education,null as marital_status,null as military_status,
    null as nation, null as native_place,null as politics_status
from t_user
where id in (select max(id) from t_user group by LOGINNO) and LOGINNO <>'' and LOGINNO not in (select a.TELEPHONE from `obpm2`.tenant_users a)
