[英]Progess 4GL - How to filter multiple records using AND operator in one table field?
I want to check and filter only if the table has value1 = 005 and value1 = 009. But it seems below query is not helping me.我只想在表具有 value1 = 005 和 value1 = 009 时检查和过滤。但似乎下面的查询对我没有帮助。 I dont know where I am making mistakes.我不知道我在哪里犯了错误。 Kindly help to solve this.请帮助解决这个问题。 Note - I cannot use where not as it may have many different value stored in value1 field注意 - 我不能使用 where not 因为它可能在 value1 字段中存储了许多不同的值
DEFINE TEMP-TABLE test NO-UNDO
FIELD value1 AS CHARACTER
.
EMPTY TEMP-TABLE test.
CREATE test.
ASSIGN
value1 = "005".
CREATE test.
ASSIGN
value1 = "009".
CREATE test.
ASSIGN
value1 = "001".
FOR EACH test NO-LOCK
WHERE value1 <> ""
AND (value1 = "005" AND value1 = "009")
:
MESSAGE YES.
END.
It looks like you're looking for an OR
ooperation, rather than AND
.看起来您正在寻找OR
操作,而不是AND
。
You can use can-find你可以使用 can-find
if can-find(first test WHERE value1 = "005")
AND can-find(first test WHERE value1 = "009")
then message yes.
It is safest to always use can-find(first if you're looking for a non-unique value始终使用 can-find 是最安全的(首先,如果您正在寻找非唯一值
If you want to check if both records are present you could do:如果你想检查这两个记录是否存在,你可以这样做:
DEFINE VARIABLE isPresent005 AS LOGICAL NO-UNDO.
DEFINE VARIABLE isPresent009 AS LOGICAL NO-UNDO.
DEFINE VARIABLE bothPresents AS LOGICAL NO-UNDO.
FIND FIRST test WHERE test.value1 = "005" NO-LOCK NO-ERROR.
isPresent005 = AVAIL test.
FIND FIRST test WHERE test.value1 = "009" NO-LOCK NO-ERROR.
isPresent009 = AVAIL test.
bothPresents = isPresent005 AND isPresent009.
But, if you only want to get these 2 records, you should use OR
:但是,如果你只想获得这两条记录,你应该使用OR
:
FOR EACH test WHERE test.value1 = "005" OR test.value1 = "009" NO-LOCK :
/*do stuff*/
END.
Another option if you are, maybe, looking for some additional fields might look something like this:如果您正在寻找一些额外的字段,另一种选择可能看起来像这样:
define buffer test005 for test.
define buffer test009 for test.
for each test005 no-lock where test005.customer = 1 and test005.value1 = "005",
each test009 no-lock where test009.customer = 1 and test009.value1 = "009":
display test005.customer.
end.
Use OR
instead of AND
to search the records...使用OR
而不是AND
来搜索记录...
This will return records if value1 = 005
OR value1 = 009
.如果value1 = 005
OR value1 = 009
,这将返回记录。
FOR EACH test NO-LOCK
WHERE value1 <> ""
AND (value1 = "005" OR value1 = "009")
:
MESSAGE YES.
END.
Is not possible to search using your way, because value1 cannot be two values at once, it's always one OR another .无法使用您的方式进行搜索,因为value1不能同时是两个值,它始终是 one OR another 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.