所以我有一个场景。
未来必须设置这4项申请费,且没有结束日期或结束日期。
(FeeTypeID = 16 AND FeeRequirementTypeID = 18)
(FeeTypeID = 17 AND FeeRequirementTypeID = 18)
(FeeTypeID = 18 AND FeeRequirementTypeID = 18)
(FeeTypeID = 19 AND FeeRequirementTypeID = 18)
现在我如何将它放入if语句?
答案 0 :(得分:0)
使用AND和OR:
select ...
from ...
where
(
(FeeTypeID = 16 AND FeeRequirementTypeID = 18) or
(FeeTypeID = 17 AND FeeRequirementTypeID = 18) or
(FeeTypeID = 18 AND FeeRequirementTypeID = 18) or
(FeeTypeID = 19 AND FeeRequirementTypeID = 18) or
)
and
(
end_date is null or
end_date > now() -- or whatever expression your dbms uses for today
);
编辑:我只是注意到它总是在FeeRequirementTypeID = 18.所以简单地说:
select ...
from ...
where FeeRequirementTypeID = 18
and FeeTypeID in (16,17,18,19)
and ( end_date is null or end_date > now() );