update notification_rule_details nrd SET nrd.NRL_FIRE_DATE=nrl_next_fire_date,nrd.NRL_NEXT_FIRE_DATE=cal_next_fire_date where nrd.NRD_ID=nrl_id and (nrd.NRD_NRL_ID!=3 or nrd.NRD_NRL_ID!=4);
在上面的查询中我想更新nrd.NRL_FIRE_DATE& nrd.NRL_NEXT_FIRE_DATE如果nrd.NRD_NRL_ID!= 3或nrd.NRD_NRL_ID!= 4 但它也更新了火灾日期& 3&的下一个开火日期4
答案 0 :(得分:2)
为什么不使用Not In:
update notification_rule_details nrd SET nrd.NRL_FIRE_DATE=nrl_next_fire_date,nrd.NRL_NEXT_FIRE_DATE=cal_next_fire_date where nrd.NRD_ID=nrl_id and nrd.NRD_NRL_ID Not In (3,4);
答案 1 :(得分:1)
这始终是真的:
(nrd.NRD_NRL_ID!=3 or nrd.NRD_NRL_ID!=4)
你有一个逻辑问题。
也许你想要
and nrd.NRD_NRL_ID!=3 and nrd.NRD_NRL_ID!=4
答案 2 :(得分:1)
您只需使用NOT IN()
即可:
UPDATE notification_rule_details nrd
SET nrd.NRL_FIRE_DATE=nrl_next_fire_date
,nrd.NRL_NEXT_FIRE_DATE=cal_next_fire_date
WHERE nrd.NRD_ID=nrl_id
AND nrd.NRD_NRL_ID NOT IN(3,4);