Export (0) Print
Expand All
ABS
ALL
AND
ANY
AVG
bit
COS
COT
DAY
EXP
GO
IN
LEN
LOG
MAX
MIN
NOT
OR
PI
SET
SIN
STR
SUM
TAN
USE
VAR
Expand Minimize
0 out of 2 rated this helpful - Rate this topic

OR

SQL Server 2000

Combines 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.

Syntax

boolean_expression OR boolean_expression

Arguments

boolean_expression

Is any valid Microsoft® SQL Server™ expression that returns TRUE, FALSE, or UNKNOWN.

Result Types

Boolean

Result Value

OR returns TRUE when either of the conditions is TRUE.

Remarks

This table shows the result of the OR operator.

  TRUE FALSE UNKNOWN
TRUE TRUE TRUE TRUE
FALSE TRUE FALSE UNKNOWN
UNKNOWN TRUE UNKNOWN UNKNOWN

Examples

This example retrieves the book titles that carry an advance greater than $5,500 and are either business or psychology books. If the parentheses are not included, the WHERE clause retrieves all business books or psychology books that have an advance greater than $5,500.

USE pubs
GO
SELECT SUBSTRING(title, 1, 30) AS Title, type
FROM titles
WHERE (type = 'business' OR type = 'psychology') AND
   advance > $5500
ORDER BY title
GO

Here is the result set:

Title                          type         
------------------------------ ------------ 
Computer Phobic AND Non-Phobic psychology   
Life Without Fear              psychology   
You Can Combat Computer Stress business     

(3 row(s) affected)

See Also

Expressions

Functions

Operators (Logical Operators)

SELECT

WHERE

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.