一条sql语句查询多个字段不为NA的笨方法

今天,在实施工作中,遇到了sql语句查询,里面的数据表有二十几个的值都为NA,要是一条条查询的话,基本查询语句如下:

select 字段名 from table_name where 字段名!='NA';

但是后来想到里面有二十多条数据表都为NA,一条条查询的方法太麻烦了,后来我就想到能不能一条语句关联,全部查询出来,语句如下:

 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'

以上就是相关的查询方法,虽然吧都差不多,但是连起来相对简单一点。如果大神们看到有新的想法,欢迎留言,谢谢!

 

 

posted on 2019-11-09 09:29  小斑马咯  阅读(683)  评论(2编辑  收藏  举报