Query By Form definition

Previous Next

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 corresponds to 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%

<column> LIKE 'H%'

*

Wildcard

H*

<column> LIKE 'H%'

_

Wildcard

H_H

<column> LIKE 'H_H'

?

Wildcard

H?H

<column> LIKE 'H_H'

NULL

NULL

NULL

<column> IS NULL

\

Escape

\<TAG\>

<column> = '<TAG>'

\\

\

\\AND\%

<column> = '\AND%'

The following table describes the operators that can be used:

Token

Description

Field filling

Resulting where clause

<

Less than

< 5

<column> < 5

<=

Less equal

<= 5

<column> <= 5

=

Equal

= 5

<column> = 5

>

Greater

> 5

<column> > 5

>=

Greater equal

>= 5

<column> >= 5

!

Not

!ABC

NOT (<column> = 'ABC')

 

 

!>5

NOT(<column> > 5)

 

 

!ABC%

NOT(<column> LIKE 'ABC%')

&

And

>5 & <10

<column> > 5 AND <column> < 10

|

Or

5 | 6

<column> = 5 OR <column> = 6

()

Nesting of conditions

!(5 | 6)

NOT (<column> = 5 OR <column> = 6)

 

 

(>5 & < 7)|

(>10 & < 20)

( <column> > 5 AND <column> < 7) OR

(<column> > 10 AND <column> < 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

        ;