You use relational operators to compare a value with other values. The result is a boolean expression whose value is always TRUE or FALSE.
Since the result of a boolean expression is always TRUE or FALSE, a relational operator that compares a value to NULL, evaluates to FALSE. For example, the expression "column > 5" evaluates to FALSE (and "NOT column > 5" evaluates to TRUE) when the column value is NULL.
When you write an expression, you can use the following relational operators (more information about LIKE, IN, and BETWEEN follows the table):
You can use the following special characters with relational operators that take string values:
Use LIKE to search for strings that match a predetermined pattern. Use NOT LIKE to search for strings that do not match a predetermined pattern. When you use LIKE or NOT LIKE, you can use the % or _ characters to match unknown characters in a pattern.
For example, the following expression for the Background.Color property of the Salary column displays salaries in red for employees with last names beginning with F and displays all other salaries in white:
If(emp_lname LIKE'F%',RGB(255,0,0),RGB(255,255,255))
Use BETWEEN to check if a value is within a range of values. Use NOT BETWEEN to check if a value is not in a range of values. The range of values includes the boundary values that specify the range.
For example, the following expression for the Background.Color property of the Salary column displays salaries in red when an employee’s salary is between $50,000 and $100,000 and displays all other salaries in white:
If(salary BETWEEN 50000 AND 100000, RGB(255,0,0), RGB(255,255,255))
You can use the BETWEEN and NOT BETWEEN operators with string values. For example, if the following expression is used for the Visual property of a column, column values display only for departments listed alphabetically between Finance and Sales:
If(dept_name BETWEEN 'Finance' AND 'Sales',1,0)
The % or _ characters can be used when you are using string values with the BETWEEN and NOT BETWEEN operators. This example might include more department listings than the previous example:
If(dept_name BETWEEN 'F%' AND 'S%',1,0)
You can also use the BETWEEN and NOT BETWEEN operators with methods. For example:
GetRow( ) BETWEEN 5 AND 8
Use IN to check if a value is in a set of values. Use NOT IN to check if a value is not in a set of values.
For example, the following expression for the Background.Color property of the Salary column displays salaries in red for employees in department 300 or 400 having a salary between $50,000 and $100,000, and displays all other salaries in white:
If(dept_id IN (300,400) and salary BETWEEN 50000 AND 100000, RGB(255,0,0), RGB(255,255,255))
Copyright © 2004. Sybase Inc. All rights reserved. |
![]() |