[xquery-talk] sequence membership operator (in)

Jonathan Robie jonathan.robie at datadirect.com
Mon Feb 13 13:58:45 PST 2006

manavaputra at yahoo.com wrote:

>I am just curious, if the membership operator like
>"in" of SQL was ever considered in xquery? Right now,
>i see i could do something equivalent using the
>sequence functions  index-of() and empty(), but some
>think like "in" would have been much more concise and

This is pretty easy to do in XQuery. Instead of using IN like this:

SELECT * FROM Customers WHERE State IN ('Alabama', 'Alaska',
'California', 'Louisiana', 'Maryland', 'Pennsylvania', 'Tennessee',

Use a general comparison =, which has implicit existential quantification:

for $c in //customer
where $c/state =  ('Alabama', 'Alaska',
'California', 'Louisiana', 'Maryland', 'Pennsylvania', 'Tennessee',
return $c

Hope this helps!


Read my Blog: http://blogs.datadirect.com/jonathan_robie/
Learn XQuery: http://media.datadirect.com/download/docs/ddxquery/tutorial_query.html
Learn XQJ (the JDBC for XQuery): http://www.datadirect.com/developer/xquery/topics/xqj_tutorial/
Get DataDirect XQuery: http://www.datadirect.com/products/xquery/

More information about the talk mailing list