October 10, 2019
Queries in SQL
DISTINCT is used to return unique values in the output. It filters out all duplicate values in the specified column(s).
* ALL
_ One character
% Multiple characters
It is not possible to test for NULL values with comparison operators, such as = and !=. Instead, we have to use IS NULL or IS NOT NULL.
BETWEEN is used in a where clause to filter results with a certain range. WHERE year BETWEEN 1974 AND 1984;
We can sort the results using ORDER BY, either alphabetically or numerically.
LIMIT is a clause that lets you specify the maximum number of rows the result set will have.
- always goes at the end of the query
- not supported by all databases
CASE statement allows us to create different outputs. It’s SQL’s way of handling if-then logic.
- usually in the SELECT statement