Reputation: 375
How can use I use or in Query?
I want to return if name ="Michael" or age =21. that is what I have
$d[contains((name,"Michael") or (age,"21"))]
Upvotes: 0
Views: 2992
Reputation: 16917
If you want to check if they are = :
$d[name = "Michael" or age = "21"]
or if you actually want to use contains:
$d[contains(name,"Michael") or contains(age,"21")]
When you write contains((,) or (,) )
you are seemingly using or
on a syntactical level, giving two different to the xquery parser. That is not possible in Xquery, or generally most programming languages, since their functions and operands operate on the values of the expressions, not on their syntax. (name,"Michael")
however has no value (well, it has the value of a two element sequence, but that is not the value you are interested in), only contains(name,"Michael")
has the actual value, of the test, if name
contains "Michael"
. So the or has to be between two calls to contains
.
Upvotes: 2