sql 根据where后面的条件判断是否添加符合的条件

2017-11-10  本文已影响0人  不相柠檬

标题写的有点拗口,描述一下场景。表t 有列Pnump ,  pstatus  ,Pmasternum 。

需求:查询t表 当pstatus为1或9的时候 需要在where后面添加条件Pmasternum is null


select * from t where(

      ( pstatus in('1','9') and Pmasternum is null) or pstatus not in('1','9') )

上一篇 下一篇

猜你喜欢

热点阅读