---
sourceDocument: Xanadu ServiceNow AI Platform Administration
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/platform-administration

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu ServiceNow AI Platform Administration

ft:clusterId :

    - platadm

bundleId :

    - platadm

workflow :

    - Platform


---

# Use disjunctions in complex queries

# Using disjunctions in complex queries {#ariaid-title1}

* Release version: Xanadu
* 
* Updated July 31, 2025
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

ServiceNow performs conjunction (AND) statements before disjunction (OR) statements in a query.

When you create a complex query that combines AND and OR conditions, you must use parenthesis around disjunctions to ensure proper grouping of query elements.

## Example {#c_UseDisjunctionsInComplexQueries__section_on3_2gn_yhc}

Find all closed incidents (state = 6) that are either Priority 1 or Priority 2.

* Correct query (with parentheses):

      (priority = 1 || priority = 2) && state = 6

  This query returns all closed incidents where the priority is 1 OR 2.
* Incorrect query (without parentheses):

      priority = 1 || priority = 2 && state = 6

  Without parentheses, this query is evaluated as: priority = 1 OR (priority = 2 AND state = 6). This returns ALL Priority 1 incidents regardless of state, plus only the closed Priority 2 incidents.

{#c_UseDisjunctionsInComplexQueries__ul_sw2_4gn_yhc} {#c_UseDisjunctionsInComplexQueries__table_kfj_vgn_yhc__entry__3}

| Query | Evaluated as | Result |
|-|-|-|
| (priority = 1 || priority = 2) && state = 6 | (P1 OR P2) AND Closed | Closed P1 and P2 incidents only |
| priority = 1 || priority = 2 && state = 6 | P1 OR (P2 AND Closed) | ALL P1 incidents + only closed P2 |
[Table 1. Comparison]

{#c_UseDisjunctionsInComplexQueries__table_kfj_vgn_yhc}

Always use parentheses around OR conditions when combining them with AND conditions. This ensures your query returns the expected results.
**Related concepts**   

* [Database view creation](https://servicenow-prod.fluidtopics.net/a2KsLerbK3uXQvXwtKIIAg "Create a database view to join tables. You can then create a report based on the database view.")
* [Displaying function results in a database view](https://servicenow-prod.fluidtopics.net/kTnvPDax3tKT97CkQE7Xig "Enhance the display of a database view by adding a function field to the output to display function results.")  
**Related reference**   

* [Database views in the base system](https://servicenow-prod.fluidtopics.net/1m0H~JIy87XpAgjHjRl20w "Certain views are included in the base system with the Database Views and Database Views for Service Management plugins.")

