# Generalized selection

In relational algebra, a generalized selection is a unary operation written as ${\displaystyle \sigma _{\varphi }(R)}$ where ${\displaystyle \varphi }$ is a propositional formula that consists of atoms as allowed in the normal selection and the logical operators ${\displaystyle \land }$ (and), ${\displaystyle \lor }$ (or) and ${\displaystyle \lnot }$ (negation). This selection selects all those tuples in ${\displaystyle R}$ for which ${\displaystyle \varphi }$ holds.

For an example, consider the following tables where the first table gives the relation ${\displaystyle Person}$ and the second the result of ${\displaystyle \sigma _{Age\geq 30\ \land \ Weight\leq 60}(Person)}$.

${\displaystyle Person}$ ${\displaystyle \sigma _{Age\geq 30\ \land \ Weight\leq 60}(Person)}$
Name Age Weight
Harry 34 80
Sally 28 64
George 29 70
Helena 54 54
Peter 34 80
Name Age Weight
Helena 54 54

Formally the semantics of the generalized selection is defined as follows:

${\displaystyle \sigma _{\varphi }(R)=\{\ t:t\in R,\ \varphi (t)\ \}}$

The result of the selection is only defined if the attribute names that it mentions are in the header of the relation that it operates upon.

The generalized selection is expressible with other basic algebraic operations. A simulation of generalized selection using the fundamental operators is defined by the following rules:

${\displaystyle \sigma _{\varphi \land \psi }(R)=\sigma _{\varphi }(R)\cap \sigma _{\psi }(R)}$
${\displaystyle \sigma _{\varphi \lor \psi }(R)=\sigma _{\varphi }(R)\cup \sigma _{\psi }(R)}$
${\displaystyle \sigma _{\lnot \varphi }(R)=R-\sigma _{\varphi }(R)}$

In SQL, general selections are performed by using WHERE definitions with AND, OR, or NOT operands in SELECT, UPDATE, and DELETE statements.