Logical Operators. 



Conditions can be linked together with the following logical 

 operators: 



(A) .OR. (B) records meeting either condition (A) or (B) 

 (A) .AND. (B) only records meeting both conditions (A) and (B) 

 (A) .AND. .NOT. (B) only records meeting condition (A) and not 



meeting condition (B) 



Make sure that periods are placed both in front of and behind the 

 logical operators; they are an essential part of the code. 



Substring Searches. 



In dBASE III, the dollar sign {"$") means "is contained in." for 

 example, 



"YELL" $COUNTIES 



means "the character string 'YELL' is contained in the field called 

 'COUNTIES.' Notice that the substring you are searching for must be 

 contained in quotation marks. If these quotation marks are not 

 included, the query won't work. 



Conversion to upper case. 



if you're not sure if the substring you're searching for within a 

 field is in upper case, lower case, or mixed, convert the field 

 contents to upper case as follows: 



"YELL" $UPPER(COUNTIES) 



This will retrieve the record whether the county name has been 

 entered as "Yell," "yell," or "YELL". 



Substring operation 



Sometimes you are only interested in part of a field, e.g., the first 

 two digits of the water code designate the drainage, and you may be 

 interested in these two only. The substring operation is used to 

 select a substring from a field, for example, for the code "021476," 



SUBSTR(C0DE,1,2) = "02" (displays two characters beginning with the 



first) 



SUBSTR(C0DE,4,3) = "476" (displays three characters beginning with 



the fourth) 



Conversion from character to numeric. 



Most fields in the Montana Rivers Study data bases are either 

 "character" (that is, they're treated simply as character strings) or 

 "numeric" (that is, only numbers are allowed and they're treated a 

 special way). Although a character field may contain only numbers, 

 as with the "CODE" field, you cannot treat them as numbers (that is, 

 you cannot perform calculations or comparisons on them) unless they 

 are first converted to numeric. This is done using the "VAL()" 

 function. For example, the following shows an incorrect way and the 



3-10 



