sql语句查询加判断

SELECT
    sph.id,
    spa.user_id,
    spa.patient_id,
    sph.group_id,
    sph.org_code,
    dhmg.group_name,
    pi.name,
    pi.mobile,
        IF(sms.STATUS = 1, sms.maker_user_name, NULL) AS maker_user_name,
        IF(sms.STATUS = 1, sms.gmt_created, NULL) AS manage_scheme_gmt_created,
    sms.maker_user_name AS maker_user_name1,
        sms.gmt_created AS manage_scheme_gmt_created1,
    hcgm.company_id,
    hcgm.company_name,
        IF(sms.STATUS = 1,IF(sms.gmt_created IS NULL, 0, 1 ),NULL) AS health_psc,
        IF( sms.gmt_created IS NULL, 0, 1 ) AS health_psc1
FROM
    family_doctor.srcd_patient_archives spa
    LEFT JOIN family_doctor.srcd_patient_hmgroup sph ON spa.patient_id = sph.patient_id 
    AND spa.is_deleted = 0 
    AND sph.is_deleted = 0
    LEFT JOIN family_doctor.dhmp_health_manage_group dhmg ON sph.group_id = dhmg.id 
    AND dhmg.is_deleted = 0
    LEFT JOIN family_doctor.patient_info pi ON spa.patient_id = pi.patient_id 
    AND pi.is_deleted = 0
    LEFT JOIN family_doctor.srcd_manage_scheme sms ON sph.patient_id = sms.patient_id 
    AND sms.is_deleted = 0
    LEFT JOIN family_doctor.huayou_company_group_mapping hcgm ON hcgm.group_id = sph.group_id 
    AND hcgm.is_deleted = 0 
WHERE
    sph.id IN (_ID_FILTER_)

你可能感兴趣的:(java,sql,linq,c#)