Where, From, And Others
WHERE
- the where clause tells us the predicate to pick entries
- relational and logical operators may be used in the predicate
- we can also compare tuples against tuples, i.e. WHERE (A, B) < (C, D)
FROM
- the from clause gives us the domain of the query
instructor X teaches
becomes FROM instructor, teaches
- common attributes get a prefix of at the start of their name
AS
- the
AS
operator can be used to rename pretty much anything
- it can also be omitted giving the same result.
instructor AS T
and instructor T
do the same thing
ORDER BY
- ORDER BY tells SQL the order to return result rows of the query in
- can be done on multiple attributes for primary and secondary sorting keys
desc
or asc
can be put at the end of each sorting key to specify the order of sorting
Between / and
- the between operator is a really dumb way to use \(\geq\) and \(\leq\) together.
WHERE salary between 90000 and 100000