数据库查询与从2个非空

时间:2017-12-01 11:38:49

标签: sql oracle performance

select FCPDD.AUDIENCE_ID,FCPD.APPLICATION_RULE_ID,FCPD.PROGRAMME_PART,FCPD.TARGET_DATE,FCPD.TIMEBAND_START_TIME,
FCPD.TIMEBAND_END_TIME,FCPD.DAY_NUMBER
FROM FPR_CHANNEL_PROCESS_DATA FCPD,FPR_CHANNEL_PROCESS_DATA_DTL FCPDD 
WHERE FCPD.CHANNEL_PROCESS_DATA_ID=FCPDD.CHANNEL_PROCESS_DATA_ID and FCPD.TARGET_DATE is not null and FCPDD.AUDIENCE_ID is not null 
and FCPD.APPLICATION_RULE_ID is not null and FCPD.PROGRAMME_PART is not null and FCPD.TIMEBAND_START_TIME is not null
and FCPD.TIMEBAND_END_TIME is not null and FCPD.DAY_NUMBER is not null 

我们可以用精确的形式编写上述查询吗

1 个答案:

答案 0 :(得分:0)

参考链接: Using IS NOT NULL for multiple columns

试试这个,

SELECT FCPDD.AUDIENCE_ID,FCPD.APPLICATION_RULE_ID,FCPD.PROGRAMME_PART,FCPD.TARGET_DATE,FCPD.TIMEBAND_START_TIME,
FCPD.TIMEBAND_END_TIME,FCPD.DAY_NUMBER
FROM FPR_CHANNEL_PROCESS_DATA FCPD,FPR_CHANNEL_PROCESS_DATA_DTL FCPDD 
WHERE FCPD.CHANNEL_PROCESS_DATA_ID=FCPDD.CHANNEL_PROCESS_DATA_ID AND 
NOT(FCPD.TARGET_DATE IS NULL 
OR FCPDD.AUDIENCE_ID IS NULL 
OR FCPD.APPLICATION_RULE_ID IS NULL 
OR FCPD.PROGRAMME_PART IS NULL 
OR FCPD.TIMEBAND_START_TIME IS NULL
OR FCPD.TIMEBAND_END_TIME IS NULL 
OR FCPD.DAY_NUMBER IS NULL )

试试这个:

SELECT FCPDD.AUDIENCE_ID,FCPD.APPLICATION_RULE_ID,FCPD.PROGRAMME_PART,FCPD.TARGET_DATE,FCPD.TIMEBAND_START_TIME,
FCPD.TIMEBAND_END_TIME,FCPD.DAY_NUMBER
FROM FPR_CHANNEL_PROCESS_DATA FCPD,FPR_CHANNEL_PROCESS_DATA_DTL FCPDD 
WHERE (FCPD.CHANNEL_PROCESS_DATA_ID=FCPDD.CHANNEL_PROCESS_DATA_ID AND 
NOT(FCPD.TARGET_DATE IS NULL 
OR FCPDD.AUDIENCE_ID IS NULL 
OR FCPD.APPLICATION_RULE_ID IS NULL 
OR FCPD.PROGRAMME_PART IS NULL 
OR FCPD.TIMEBAND_START_TIME IS NULL
OR FCPD.TIMEBAND_END_TIME IS NULL 
OR FCPD.DAY_NUMBER IS NULL ))