You can combine predicates with AND and OR:
The default order of evaluation is AND before OR. You can use parentheses to override the default order.
How It's Done
The Human Resources department needs to identify employees who live in Camden, Brookline, or Canton and who have telephones in order to set up a calling network. You created both of these search conditions earlier in this chapter. Now you want to combine them.
To produce this list, enter:
select emp_id, city, phone
from employee
where city in ('Camden', 'Brookline', 'Canton')
and phone is not null;
The result looks like this:
EMP_ID CITY PHONE ------ ---- ----- 3338 Canton 6179238844 3082 Camden 5089273644 4660 Camden 5092344620 2209 Brookline 6175563331 5090 Canton 5083389935 3222 Brookline 6176635520 2096 Brookline 6175553643 5103 Brookline 6176600684 5008 Brookline 6176642209 3764 Brookline 6179458377 1234 Brookline 6176646602 2174 Brookline 6176633854 4703 Brookline 6176648290 3294 Brookline 6175567551 3118 Canton 5083766984 15 rows processed
|
Copyright © 2014 CA.
All rights reserved.
|
|