|
|
|
|
| |
Table 1.3. Logical Operators
| Operator |
Meaning |
| AND |
Logical AND |
| OR |
Logical OR |
| XOR |
Logical ExclusiveOR |
| NOT |
Logical negation |
When you're formulating a query that requires logical operators, take care not to confuse the meaning of the logical AND operator with the way we use "and" in everyday speech. Suppose you want to find "presidents born in Virginia and presidents born in Massachusetts." That question is phrased using "and," which seems to imply that you'd write the query as follows:
mysql> SELECT last_name, first_name, state FROM president
-> WHERE state='VA' AND state='MA';
Empty set (0.36 sec)
It's clear from the empty result that the query doesn't work. Why not? Because what it really means is "Select presidents who were born both in Virginia and in Massachusetts," which makes no sense. In English, you might express the query using "and," but in SQL, you connect the two conditions with OR:
|
|
|
|
|
|
| Link Partners: Asia florist, Flowers to India, Hongkong flowers, Site submit, Cheap web hosting, China florist |
|