Evaluating Conditions in AMPscript

AMPscript supports conditional logic, enabling your marketing team to personalize each message and customer touchpoint.

In AMPscript, you can use comparison operators to compare two values. AMPscript uses the operators in this table.

OperatorDescription
==Is equal to
!=Is not equal to
>Greater than
<Less than
>=Greater than or equal to
<=Less than or equal to

These operators are commonly used in If statements. For example, this statement checks to see if the numeric value of the @age variable is 30 or higher.

You can also use join operators to join multiple conditions. AMPscript includes the join operators in this table.

OperatorDescription
andBoth conditions must be true
orEither condition must be true

You can use parentheses to control the order in which AMPscript evaluates complex expressions.

For example, this If is matched in one of two ways:

  • If the value of the @age variable is 30 or higher and the value of the @predisposition variable is "High"; or
  • If the value of the @age variable is 55 or higher and the value of the @predisposition variable is "Normal".

The not operator reverses the logic of an evaluation. For example, this statement is matched when the value of the @age variable is 55 or higher, and the value of the @predisposition variable is anything other than "High".