我有一个具有作者字段和演示者字段的事件表.来自我个人表的人既可以是同一事件的作者也可以是演示者,也可以是演示者或作者.我需要根据人员ID和他们选择的类型或过滤器对结果集应用过滤器.我有的过滤器是:
全部:返回作为作者或演示者的所有记录.
AllPresenter:所有记录作为演示者.
AllAuthor:作为作者的所有记录.
PresenterOnly:仅记录为演示者而非作者.
AuthorOnly:仅记录作者而不是演示者.
PresenterAndAuthorOnly:他们是演示者和作者的所有记录.
我目前有一个存储过程使用外部ifs,如下所示,我试图找到一种方法将所有这些类似的select语句合并为一个.我没有太多运气找到更好的解决方案,我想知道我是否错过了一项技术.
If (@filter = 'PandAOnly' or @filter = 'AllP' or @filter = 'AllA')
begin
Select * from Event
Where
PresenterId = Case @personId is null then PresenterId else @personId end
and
AuthorId = Case @personId is null then AuthorId else @personId end
end
else if (@filter = 'All')
begin
Select * from Event
Where
PresenterId = @personId
Or
AuthorId = @personId
end
else if (@fitler = 'POnly')
begin
Select * from Event
Where …Run Code Online (Sandbox Code Playgroud) 我试图弄清楚如何从节点请求中获取请求类型.我想根据类型执行不同的任务.
module.exports = function(req, resp, next){
if (req.type == 'GET'){
//Do something
}else{
// Do else something
}
}
Run Code Online (Sandbox Code Playgroud)