A selection operator
In the syntax above:
Consider a case where we have a relation
Id | Name | Hometown | Age |
10 | Muhammad Ali | Ohio | 29 |
11 | Noah | Texas | 25 |
12 | Emma | Seattle | 20 |
13 | Arslan Ash | Lahore | 22 |
14 | Adam | Texas | 18 |
15 | Marques | California | 22 |
16 | Linus | Toronto | 22 |
The query below will return a table having only the records where the Age is equal to
The query's output from above will be as follows:
Id | Name | Hometown | Age |
13 | Arslan Ash | Lahore | 22 |
15 | Marques | California | 22 |
16 | Linus | Toronto | 22 |
We can also have multiple relational conditions in the selection operation to get desired records. Multiple conditions join with logical operations (AND, OR). For instance:
The query above will select only those rows or records with age equal to
Id | Name | Hometown | Age |
11 | Noah | Texas | 25 |
13 | Arslan Ash | Lahore | 22 |
14 | Adam | Texas | 18 |
15 | Marques | California | 22 |
16 | Linus | Toronto | 22 |
The selection operation in DBMS (Database Management System) allows us to retrieve specific records or rows from a relation based on certain conditions. Using logical operators such as AND and OR, we can combine multiple relational conditions to refine our selection and obtain the desired subset of data.
Free Resources