• Create BookmarkCreate Bookmark
• Create Note or TagCreate Note or Tag
• PrintPrint

### Operators

In the previous section, you were introduced to the use of the & operator. Operators are used in programming languages to aid in the evaluation of expressions. The following table lists operators with which you should become familiar:

OperatorDescription
*The multiplication operator is used when multiplying fields or values.
/The divide operator is used when dividing fields or values.
The minus operator is used when subtracting fields or values.
>The greater-than operator is used in WHERE clauses to determine whether a first value is greater than the second, such as:
```SELECT *
FROM Employees
WHERE EmployeeID > 10
```

The result returns all the EmployeeIDs after 10.
<The less-than operator is used in WHERE clauses to determine whether a first value is less than the second, such as:
```SELECT *
FROM Employees
WHERE EmployeeID < 10
```

The result returns EmployeeIDs 1–9.
>=The greater than or equal to operator is used in WHERE clauses to determine whether a first value is greater than or equal to the second, such as:
```SELECT *
FROM Employees
WHERE EmployeeID >= 10
```

The result returns EmployeeIDs of 10 and greater.
<=The less than or equal to operator is used in WHERE clauses to determine whether a first value is less than or equal to the second, such as:
```SELECT *
FROM Employees
WHERE EmployeeID <= 10
```

The result returns all the EmployeeIDs between 1 and 10.
<>, !=Used to check whether a value is not equal to a second.
ANDTypically used with the WHERE clause in the SELECT statement. The AND operator returns a second value, such as:
```SELECT *
FROM Employees
WHERE EmployeeID = 1 AND EmployeeID = 2
```

ORTypically used with the WHERE clause in the SELECT statement. The OR operator can be used when a certain condition needs to be met or when you can settle for a second, such as:
```SELECT *
FROM Employees
WHERE EmployeeID = 1 OR EmployeeID = 2
```

LIKEThe LIKE operator is generally used with WHERE clauses when a wildcard needs to be performed, such as:
```SELECT *
FROM Employees
WHERE Name LIKE 'A%'
```

This result returns all employees whose names start with A. Our result returns Ada and Agnes because both their names begin with the letter A.
NOTTypically used in conjunction with the LIKE operator, the NOT operator is used when a value is not going to be LIKE the value of a second, such as:
```SELECT *
FROM Employees
WHERE Name NOT LIKE 'A%'
```

In this case, all names other than Ada and Agnes are returned.
%The multiple-character operator is similar to the underscore operator except that it allows for multiple characters, whereas the underscore operator allows for only two. This operator is used in more situations than the underscore operator.
_The underscore operator is used with WHERE clauses and is performed when you do not know the second value, such as:
```SELECT *
FROM Employees
WHERE BillingShippingState LIKE 'A_'
```

The result, in this case, returns all states that begin with the letter A, such as AK, AL, AR, and AZ.

PREVIEW

Not a subscriber?

Start A Free Trial

• Create BookmarkCreate Bookmark
• Create Note or TagCreate Note or Tag
• PrintPrint