keeps the tuples of a relation that make a condition true:
text
σ dept_name = 'Physics' (instructor)instructor
| id | name | dept_name | salary |
|---|---|---|---|
| I101 | Amara Osei | Comp. Sci. | 92000 |
| I103 | Helen Park | Math | 81000 |
| I104 | Jonas Berg | Physics | 87000 |
| I105 | Clara Mendes | History | 62000 |
| I108 | Owen Grant | Physics | 69000 |
In SQL, the condition goes in WHERE:
sql
SELECT * FROM instructor WHERE dept_name = 'Physics';Conditions
A condition compares attributes with values or with other attributes, and joins comparisons with logical connectives:
| Algebra | SQL |
|---|---|
= ≠ < ≤ > ≥ | = <> < <= > >= |
∧ (and) | AND |
∨ (or) | OR |
¬ (not) | NOT |
What selection does not do
- It never removes attributes. The result has the same schema as the input.
- It never adds tuples. The result has at most as many tuples as the input.
- Two selections in a row are one selection with
∧:
text
σ a (σ b (r)) = σ a ∧ b (r)