LOOKUP_FIELD "field_name" $variable_name FROM / SQL normal_loop_clause_syntax

LOOKUP_FIELD combines a normal LOOP with an embedded VARIABLE_FIELD command, to extract a single piece of data from a single row of the database.

If multiple rows are returned by the loop command portion, each successive row will overwrite the variable with the data from the relevant field. While this may seem odd, it does have its uses; by listing rows in date order, for example, you can find out data for the last talk heard (for a brother, a talk number, etc.).

normal_loop_clause_syntax refers to a normal WHERE clause (FROM) or a proper SQL statement (SQL). See the LOOP topic for more information.

Note that the front half is the same syntax as VARIABLE_FIELD.


(Statement split over multiple physical lines for clarity only)

LOOP FROM "Home Talks" SORTBY "Last Given"
    LOOKUP_FIELD "Coordinator" $strCoordinator 
                 FROM "Congregations" NODATERANGE 
                 WHERE "Congregations" IS CURRENT."Congregation"
    TEXT "$strCoordinator"