The logical operators AND, OR, and NOT are used to connect search conditions in WHERE clauses. When more than one logical operator is used in a statement, AND operators are normally evaluated before OR operators. You can change the order of execution with parentheses.
The AND operator joins two or more conditions and returns results only when all the conditions are true. For example, the following query finds only the rows in which the contact's last name is Purcell and the contact's first name is Beth.
SELECT * FROM Contacts WHERE GivenName = 'Beth' AND Surname = 'Purcell'; |
The OR operator connects two or more conditions and returns results when any of the conditions is true. The following query searches for rows containing variants of Elizabeth in the GivenName column.
SELECT * FROM Contacts WHERE GivenName = 'Beth' OR GivenName = 'Liz'; |
The NOT operator negates the expression that follows it. The following query lists all the contacts who do not live in California:
SELECT * FROM Contacts WHERE NOT State = 'CA'; |
Discuss this page in DocCommentXchange. Send feedback about this page using email. |
Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1 |