查询条件为功能 [英] Query criteria as function

查看:111
本文介绍了查询条件为功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SELECT * FROM tblLabor WHERE tblLabor.UserGroup = SetUserGroupCriteria()


我在我正在使用的查询中有类似的东西。我希望SetUserGroupCriteria()返回

[类似CA *的行]。不喜欢RN *不幸的是,SetUserGroupCriteria()返回一个看起来像[LikeCA *的字符串。并且不喜欢RN *"],并且关键字Like会自动地抛到这整个混乱的前面,从而使它说:

喜欢LikeCA *"而不是像RN *那样。不用说,这是不可取的。有什么我可以做的纠正他吗?

SELECT * FROM tblLabor WHERE tblLabor.UserGroup=SetUserGroupCriteria()

I have something similar to this in a query that I''m using. I want SetUserGroupCriteria() to return something along the lines of
[Like "CA*" and Not like "RN*"] Unfortunately SetUserGroupCriteria() returns a string that looks like ["Like "CA*" and Not like "RN*""], and the keyword Like gets thrown in front of this whole mess automatically, thus making it say:
Like "Like "CA*" and Not like "RN*"". Needless to say, this is not desirable. Is there anything I can do to correct his?

推荐答案


SELECT * FROM tblLabor WHERE tblLabor.UserGroup = SetUserGroupCriteria( )


在我正在使用的查询中,我有类似的东西。我希望SetUserGroupCriteria()返回

[类似CA *的行]。不喜欢RN *不幸的是,SetUserGroupCriteria()返回一个看起来像[LikeCA *的字符串。并且不喜欢RN *"],并且关键字Like会自动地抛到这整个混乱的前面,从而使它说:

喜欢LikeCA *"而不是像RN *那样。不用说,这是不可取的。有什么我可以做的纠正他的吗?
SELECT * FROM tblLabor WHERE tblLabor.UserGroup=SetUserGroupCriteria()

I have something similar to this in a query that I''m using. I want SetUserGroupCriteria() to return something along the lines of
[Like "CA*" and Not like "RN*"] Unfortunately SetUserGroupCriteria() returns a string that looks like ["Like "CA*" and Not like "RN*""], and the keyword Like gets thrown in front of this whole mess automatically, thus making it say:
Like "Like "CA*" and Not like "RN*"". Needless to say, this is not desirable. Is there anything I can do to correct his?



您好Sandro997,

SetUserGroupCriteria是否在其他任何地方使用?

如果它不是更容易改进这一点,而不是重新格式化文本字符串。你能粘贴函数SetUserGroupCriteria()的代码吗?


Thx

Hi Sandro997,
Is SetUserGroupCriteria used anywhere else?
If it isn''t it might easier to refine this than mess around re-formatting the text string. Could you paste the code for the function SetUserGroupCriteria()?

Thx


如果你发布 SetUserGroupCriteria的代码( )
然后我们可以告诉你。

它可以合理地直截了当。
If you post the code for SetUserGroupCriteria()
then we can tell you.
It will propably be reasonably straightforward.



你好Sandro997,

SetUserGroupCriteria是否在其他任何地方使用过?

如果它不是更容易改进这个而不是重新格式化文本字符串。你能粘贴函数SetUserGroupCriteria()的代码吗?


Thx
Hi Sandro997,
Is SetUserGroupCriteria used anywhere else?
If it isn''t it might easier to refine this than mess around re-formatting the text string. Could you paste the code for the function SetUserGroupCriteria()?

Thx



雅,这个函数遍及整个
公共函数SetUserGroupCriteria()As String

Select Case GetUserGroupByUserID(fGetUserID())

Case" UserType1" SetUserGroupLikeCriteria =" Not like"" CA *""并且不喜欢" RN *""

Case" UserType2" SetUserGroupLikeCriteria =" Not like"" LS *""并且不喜欢" FM *"""

Case" UserType3" SetUserGroupLikeCriteria =" Not like""" FM *"""

Case" UserType4" SetUserGroupLikeCriteria =" Like"" *"""

Case" UserType5" SetUserGroupLikeCriteria =" Like"" CA *""和喜欢"FM *"""

结束选择

结束功能


有一个公平那里有一点逻辑

希望这有助于

Ya, this function is used all over the place.

Public Function SetUserGroupCriteria() As String
Select Case GetUserGroupByUserID(fGetUserID())
Case "UserType1" SetUserGroupLikeCriteria = "Not like ""CA*"" and Not like ""RN*"""
Case "UserType2" SetUserGroupLikeCriteria = "Not like ""LS*"" and Not like ""FM*"""
Case "UserType3" SetUserGroupLikeCriteria = "Not like ""FM*"""
Case "UserType4" SetUserGroupLikeCriteria = "Like ""*"""
Case "UserType5" SetUserGroupLikeCriteria = "Like ""CA*"" and Like ""FM*"""
End Select
End function

There is a fair bit of logic in there
Hope this helps


这篇关于查询条件为功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆