今天写sql 时 需要条件 加入两个 where 里的条件
if(条件1 is true)
{
添加 where 条件1
}
if(条件2 is true)
{
添加 where 条件2
}
结果 就有可能 2×2 种情况
这时只需要 将 where 提出, 具体条件里 改为 and 即可
where
1=1
if(条件1 is true)
{
添加 and 条件1
}
if(条件2 is true)
{
添加 and 条件2
}