SELECT
SummaryParts of the SELECT
statement
SELECT |
Lists the columns from base tables to be projected into the table that will be the result of the command. |
FROM |
Identifies the tables from which the columns will be chosen to appear in the resulting table, and includes the tables needed to join tables to process the query. |
WHERE |
Includes the conditions for row selection from within a single table and the conditions between the tables for joining. Because SQL is considered a set manipulation language, the WHERE clause is important for defining the set of rows being manipulated. |
GROUP BY |
Groups rows in an intermediate results table where the values in those rows are the same for one or more columns. |
HAVING |
Can only be used following a GROUP BY and acts as a secondary WHERE clause, returning only those groups that meet a specified condition. |
ORDER BY |
Sorts the final results rows in ascending or descending order. |
Comparison operators
Operator | Meaning |
---|---|
= | equal to |
> | greater than |
>= | greater than or equal to |
< | less than |
<= | less than or equal to |
Aggregate Functions
Aggregate functions return single result row based on groups of rows, rather than on single rows. They are also used with the GROUP BY statement.
Function
Description
AVG
Finds the average
COUNT
Counts the number of records found
MAX
Finds the maximum
MIN
Finds the minimum
SUM
Sums the total
Boolean Operators
AND |
Returns TRUE if both component conditions are TRUE . Returns FALSE if either is FALSE . |
OR |
Returns TRUE if either component condition is TRUE . Returns FALSE if both are FALSE . |
NOT |
Returns TRUE if either component condition is TRUE . Returns FALSE if both are FALSE . |
String Comparison and Wild Cards
LIKE% |
Allows you to compare stings Matches any string of any length (including length 0) |