LookUp()
LOOKUP() is a very cool, but very complex, way to pull information out of a table. It lets you look up information based on one field or tag, but return information from a different field. It's kind of like many of the lists and combo boxes we set up, where the user chooses based on one piece of data, but we store a different data item behind the scenes.
Usage |
uResult = LOOKUP( FieldToReturn, uSearchExpr, SearchField [, cSearchTag ] ) |
Parameter |
Value |
Meaning |
FieldToReturn |
Name |
The name of the field whose value is returned. |
uSearchExpr |
Expression |
The value to search for. |
SearchField |
Name |
The field in which to search for uSearchExpr unless cSearchTag is included. Ignored if cSearchTag is included; see below. |
cSearchTag |
Character |
The name of an index tag that should be used to search for uSearchExpr. |
Omitted |
Search for uSearchExpr in the field SearchField. |
|
uResult |
Anything except empty value |
The search expression was found, so the value of FieldToReturn for that record is returned. |
Empty |
No record was found with the specified value. |
Example |
USE Employee * No index used for this one ? LOOKUP(Birth_Date, "Laura", First_Name) && Returns {1/9/58} * Use name index. Specification of Last_Name is ignored, but * aids in readability ? LOOKUP(Home_Phone, "FULLER", Last_Name, "Last_Name") && Returns "(206) 555-9482" * Since there's an index on Employee_Id, it's used automatically ? LOOKUP(Last_Name, " 10", Employee_Id) && Returns "Martin" |
See Also |