今天,在實施工做中,遇到了sql語句查詢,裏面的數據表有二十幾個的值都爲NA,要是一條條查詢的話,基本查詢語句以下:sql
select 字段名 from table_name where 字段名!='NA';spa
可是後來想到裏面有二十多條數據表都爲NA,一條條查詢的方法太麻煩了,後來我就想到能不能一條語句關聯,所有查詢出來,語句以下:code
1 select TP_TCM_DIFF_TREAT_BASIS, 2 OBS_RESCUE_PERSON_LIST, 3 D_PRIMARY_DIAG_C, 4 D_PRIMARY_TCM_DISEASE_C, 5 D_PRIMARY_TCM_DISEASE_N, 6 D_PRIMARY_TCM_STATE_C, 7 D_PRIMARY_TCM_STATE_N, 8 AARA_ALLERGY_HISTORY, 9 ORIC_GONE_CODE, 10 OBS_EMERGENCY_RESCUE_RECORD, 11 PAST_HISTORY, 12 HP_INTERVENING_OBJ_N, 13 HP_SURGERY_C, 14 HP_SURGERY_TIMES, 15 HP_SURGERY_OPER_METHOD, 16 HP_SURGERY_N, 17 HP_SURGERY_SITE_N, 18 PO_REMARK, 19 TP_TREAT_PRINCIPLE_METHOD, 20 D_TCM_DIAG_OBSERVE_RESULT, 21 ORIC_NOTES, 22 OBS_SPECIALTY_POST_CLASS_C 23 from ODS_JZLGBL_20191014_CX 24 where 25 TP_TCM_DIFF_TREAT_BASIS!='NA' or 26 OBS_RESCUE_PERSON_LIST!='NA' or 27 D_PRIMARY_DIAG_C!='NA' or 28 D_PRIMARY_TCM_DISEASE_C!='NA' or 29 D_PRIMARY_TCM_DISEASE_N!='NA' or 30 D_PRIMARY_TCM_STATE_C!='NA' or 31 D_PRIMARY_TCM_STATE_N!='NA' or 32 AARA_ALLERGY_HISTORY!='NA' or 33 ORIC_GONE_CODE!='NA' or 34 OBS_EMERGENCY_RESCUE_RECORD!='NA' or 35 PAST_HISTORY!='NA' or 36 HP_INTERVENING_OBJ_N!='NA' or 37 HP_SURGERY_C!='NA' or 38 HP_SURGERY_TIMES!='NA' or 39 HP_SURGERY_OPER_METHOD!='NA' or 40 HP_SURGERY_N!='NA' or 41 HP_SURGERY_SITE_N!='NA' or 42 PO_REMARK!='NA' or 43 TP_TREAT_PRINCIPLE_METHOD!='NA' or 44 D_TCM_DIAG_OBSERVE_RESULT!='NA' or 45 ORIC_NOTES!='NA' or 46 OBS_SPECIALTY_POST_CLASS_C!='NA'
以上就是相關的查詢方法,雖然吧都差很少,可是連起來相對簡單一點。若是大神們看到有新的想法,歡迎留言,謝謝!blog