Search Condition (SQL)

Help Contents

Introduction

The SQL Search Condition declares a condition that results in FALSE, TRUE, or UNKNOWN.

Syntax

search-condition ::=
  boolean-value-expression

boolean-value-expression ::=
  boolean-term
  | boolean-value-expression OR boolean-term

boolean-term ::=
  boolean-factor
  | boolean-term AND boolean-factor

boolean-factor ::=
  [ NOT ] boolean-test

boolean-test ::=
  boolean-primary [ IS [ NOT ] truth-value ]

truth-value ::=
  TRUE | FALSE | UNKNOWN

boolean-primary ::=
  predicate
  | nonparenthesized-value-primary
  | ( boolean-value-expression )

Remarks

In SQL, boolean expressions use 3-state logic, which can result in one of three values: FALSE, TRUE, or UNKNOWN. UNKNOWN is typically returned when one or more values are NULL.

The truth table of the AND operator:

ANDTrueFalseUnknown
TrueTrueFalseUnknown
FalseFalseFalseFalse
UnknownUnknownFalseUnknown

The truth table of the OR operator:

ORTrueFalseUnknown
TrueTrueTrueTrue
FalseTrueFalseUnknown
UnknownTrueUnknownUnknown

The truth table of the IS operator:

ISTrueFalseUnknown
TrueTrueFalseFalse
FalseFalseTrueFalse
UnknownFalseFalseTrue

Examples

To find all analog voltage tags that are less than 23.5 volts:

Select FullName,Value
From TagDataPointAnalog
Where Units = 'Volts' AND Value < 23.5

Further Information

Fernhill SCADA Structured Query Language (SQL)

To learn more about the SQL features in Fernhill SCADA.

Glossary

For the meaning of terms used in Fernhill SCADA.