|| (OR)
Combines two Boolean expressions.
boolean_expression OR boolean_expression
or
boolean_expression || boolean_expression
Arguments
- boolean_expression
Any valid expression that returns a Boolean.
Return Value
true when either of the conditions is true; otherwise, false.
Remarks
OR is an Entity SQL logical operator. It is used to combine two conditions. When more than one logical operator is used in a statement, OR operators are evaluated after AND operators. However, you can change the order of evaluation by using parentheses.
Double vertical bars (||) have the same functionality as the OR operator.
The following table shows possible input values and return types.
TRUE | FALSE | NULL | |
---|---|---|---|
TRUE |
TRUE |
TRUE |
TRUE |
FALSE |
TRUE |
FALSE |
NULL |
NULL |
TRUE |
NULL |
NULL |
Example
The following Entity SQL query uses the OR operator to combine two Boolean expressions. The query is based on the AdventureWorks Sales Model. To compile and run this query, follow these steps:
Follow the procedure in How to: Execute a Query that Returns StructuralType Results.
Pass the following query as an argument to the
ExecuteStructuralTypeQuery
method:
-- OR
SELECT VALUE product FROM AdventureWorksEntities.Products
AS product where product.ListPrice = @price1 OR product.ListPrice = @price2
-- ||
SELECT VALUE product FROM AdventureWorksEntities.Products
AS product where product.ListPrice = @price1 || product.ListPrice = @price2