Entering content frame

Search Condition (search_condition) 

A search_condition links statements that can be true, false, or undefined. Rows in a table may be found that fulfill several conditions that are linked with AND or OR.

Syntax

<search_condition> ::= <boolean_term> | <search_condition> OR <boolean_term>

<boolean_term> ::= <boolean_factor> | <boolean_term> AND <boolean_factor>

boolean factor: determine the boolean values (BOOLEAN) to be linked or their negation ( NOT).

Explanation

Predicates in a WHERE clause are applied to the specified row or a group of rows in a table formed with the GROUP clause. The results are linked using the specified Boolean operators (AND, OR, NOT).

If no parentheses are used, the precedence of the operators is as follows: NOT has a higher precedence than AND and OR, AND has a higher precedence than OR. Operators with the same precedence are evaluated from left to right.

NOT

x

NOT(x)

true

false

false

true

undefined

undefined

x AND y

x                        y

false

undefined

true

false

false

false

false

undefined

false

undefined

undefined

true

false

undefined

true

x OR y

x                        y

false

undefined

true

false

false

undefined

true

undefined

undefined

undefined

true

true

true

true

true

Example table: customer

Customers who live in New York or have a credit balance:

SELECT firstname, name, city, account FROM customer
WHERE city = 'New York' OR account > 0

FIRSTNAME

NAME

CITY

ACCOUNT

Jenny

Porter

New York

100.00

?

DATASOFT

Dallas

4813.50

Michael

Porter

New York

0.00

George

Howe

New York

-315.40

Joseph

Peters

Los Angeles

650.00

Mark

Griffith

New York

0.00

?

TOOLware

Los Angeles

3770.50

Rose

Brown

Hollywood

440.00

Customers who live in Hollywood and have a credit balance:

SELECT firstname, name, city, account FROM customer
WHERE city = 'Hollywood' AND account > 0

FIRSTNAME

NAME

CITY

ACCOUNT

Rose

Brown

Hollywood

440.00

 

 

Leaving content frame