字段名:Bran,block,are ,store 四个字段中存在值等于0或者不等于0,两种情况。where中如果用if等条件判断会有16中组合,如果采用where中的条件就避免了这个情况。

declare @a int

declare @b int

declare @c int

declare @d int

set @a=0

set @b=0

set @c=0

set @d=0

select * from ABC_Table

where (b.Bran =@a  or @a=0)

and  (b.block =@b or @b=0)

and  (b.are =@c or @c=0)

and  (a.store =@d or @d=0)

相关文章:

  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
  • 2022-01-06
  • 2022-12-23
  • 2022-12-23
  • 2021-11-03
猜你喜欢
  • 2021-05-27
  • 2021-05-22
  • 2021-12-20
  • 2021-05-31
  • 2022-12-23
  • 2022-12-23
  • 2021-10-12
相关资源
相似解决方案