﻿ Query By Form Definition

# Query By Form Definition

In Query By Form (QBF) format, the columns of ONE table can be queried. In its simplest form, the field values determine the query condition:

ABC

which results in this query:

SELECT     *

FROM       <table>

WHERE      <column> = 'ABC'

Wildcards, operators, and special characters can be used to refine the query:

 Token Description Example Resulting where clause % Wildcard H% LIKE 'H%' * Wildcard H* LIKE 'H%' _ Wildcard H_H LIKE 'H_H' ? Wildcard H?H LIKE 'H_H' NULL NULL NULL IS NULL \ Escape \ = '' \\ \ \\AND\% = '\AND%'

The following table describes the operators that can be used:

 Token Description Field filling Resulting where clause < Less than < 5 < 5 <= Less equal <= 5 <= 5 = Equal = 5 = 5 > Greater > 5 > 5 >= Greater equal >= 5 >= 5 ! Not !ABC NOT ( = 'ABC') !>5 NOT( > 5) !ABC% NOT( LIKE 'ABC%') & And >5 & <10 > 5 AND < 10 | Or 5 | 6 = 5 OR = 6 () Nesting of conditions !(5 | 6) NOT ( = 5 OR = 6) (>5 & < 7)| (>10 & < 20) ( > 5 AND < 7) OR ( > 10 AND < 20) AND And OR Or

'AND' and 'OR' are aliases for the '&' and '|' operators and can be used everywhere where these operators can be used.

<, <=, =, > are comparison operators. These operators are followed by a value. In combination with this value they form a Boolean expression.

A value on itself without a comparison operator is also a Boolean expression. It implicitly uses the '=' operator.

&, |, AND, OR are logical operators. These operators are preceded and followed by a Boolean expression. With these expressions they form a new Boolean expression.

! is a unary operator. This operator expects a Boolean expression on the right side. With this expression it forms a Boolean expression.

() encapsulates a Boolean expression.

In a YACC (Yet Another Compiler-Compiler) parser-like notation the definition of the syntax allowed is:

expression : VALUE

|    < VALUE

|    <= VALUE

|    = VALUE

|    > VALUE

|    >= VALUE

|    ! expression

|    expression & expression

|    expression | expression

|    ( expression )

|    expression AND expression

|    expression OR expression

;