Boolean logic: Difference between revisions

Content deleted Content added
Line 187:
</source>
 
The first example will produce a list of all employees named James Dean, the second example will produce a list of all employees whose first name is James OR whose last name is Dean, and the third example will produce a list of all employees whose last name is not Dean.
Parentheses may be used to explicitly specify the order in which Boolean operations occur, when multiple operations are present:
<source lang="sql">
SELECT * FROM employees WHERE (NOT last_name = 'Smith') AND (first_name = 'John' OR first_name = 'Mary') ;
</source>
This example will produce a list of employees named John OR named Mary, but specifically excluding those named John Smith or Mary Smith.
 
Multiple sets of nested parentheses may also be used, where needed.