• 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 that you should be familiar with:

 * 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 Customers WHERE CustomerID > 10 ``` The result would return all the CustomerIDs 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 Customers WHERE CustomerID < 10 ``` The result would return CustomerIDs 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 Customers WHERE CustomerID >= 10 ``` The result would return CustomerIDs 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 Customers WHERE CustomerID <= 10 ``` The result would return all the CustomerIDs between 1 and 10. <>, != Used to check whether a value is not equal to a second. AND Used with the WHERE clause in the SELECT statement. The AND operator returns a second value, such as ```SELECT * FROM Customers WHERE CustomerID = 1 AND CustomerID = 2 ``` OR 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 Customers WHERE CustomerID = 1 OR CustomerID > 2 ``` LIKE The LIKE operator is used with WHERE clauses when a wildcard needs to be performed, such as ```SELECT * FROM Customers WHERE LastName LIKE 'Smi%' ``` which would return all customers whose last names start with “Smi.” NOT Typically 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 Customers WHERE LastName NOT LIKE 'Smi%' ``` _ The underscore operator is used with WHERE clauses and is performed when you do not know the second value, such as ```SELECT * FROM Customers WHERE BillingState LIKE 'A_' ``` which would return all customers' states that begin with A, such as AK, AL, AR, and AZ. % 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.

PREVIEW

Not a subscriber?

Start A Free Trial

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