How to: |
The IF function tests a condition and returns a value based on whether the condition is true or false.
IF(test, val1, val2)
where:
Condition
Is an SQL search condition, which evaluates to true or false.
Are expressions of compatible types.
This function returns a value of the type of val1 and val2. If test is true, val1 is returned, otherwise val2 is returned.
This example tests COUNTRY. If the value is ENGLAND, it returns LONDON. Otherwise, it returns PARIS.
IF(COUNTRY = 'ENGLAND', 'LONDON', 'PARIS') = 'LONDON' if COUNTRY is 'ENGLAND' 'PARIS' otherwise.
This example tests COUNTRY. If the value is ENGLAND, it returns LONDON. If the value is FRANCE, it returns PARIS. Otherwise, it returns ROME.
IF(COUNTRY = 'ENGLAND', 'LONDON', IF(COUNTRY = 'FRANCE', 'PARIS', 'ROME')) = 'LONDON' if COUNTRY is 'ENGLAND' 'PARIS' if COUNTRY = 'FRANCE' 'ROME' otherwise.
iWay Software |