Reporting > Native reporting system > Using fields as variables > Using a field value in a WHERE clause
  
Using a field value in a WHERE clause
You can specify WHERE field_1 operator field_2 FIELD to designate field_2 as a field name.
If you specify '..field_2, "value_1"', the value "value_1" must also be treated as a field so you cannot set up an OR with a hard-coded value.
Fields selected or used in WHERE clauses in previous levels can also be used as comparison values. To use another field value from the same level in a WHERE clause then you must retrieve it first through another WHERE clause, because the data retrieval triggered by SELECT statements occurs after vetting of the entity against the WHERE clauses.
Examples
field x { }
TABULAR 1
{
select name as x
WHERE Class = Symbol
WHERE "Selected" = T
WHERE Current = T
JOIN
SELECT "Relation"
JOIN
SELECT "Class", "Type", "Name", Identity
where name = x field
ORDERBY "Class", "Type", "Name", Identity
}
The following example one compares Symbol names with graphic comments, which are stored in the property called Description:
TABULAR 1
{
select Name
where Name <> " " REM 'must force retrieval of the value to be compared first'
where Description <> Name field
WHERE Class = Symbol
WHERE Current = T
}
The following example is the same as the preceding example, except that the values are extracted from properties, requiring field statements:
FIELD "Purpose <-- Purpose"
{ SOURCE PROPERTY "Purpose" LENGTH 1000 TYPE MEMO LEGEND "Purpose" }
FIELD "Comments <-- Comments"
{ SOURCE PROPERTY "Comments" LENGTH 100 TYPE CHARACTER LEGEND "Comments" }
TABULAR 1
{
SELECT "Name" LEGENDFONT Font5, "Purpose <-- Purpose", "Comments <-- Comments"
where "Purpose <-- Purpose" <> "" REM 'must force retrieval of the value to be compared first'
where "Purpose <-- Purpose" <> "Comments <-- Comments" field
WHERE Class = Definition
WHERE "Type Number" = 15
ORDERBY "Name"
}
See also
Storing a selected value in a field for later use
Selecting the last-stored value of a field in a SELECT statement
Parent topic
Using fields as variables