SQL Flashcards
Is SQL a case-sensitive language?
No
Every statement must be terminated with:
A semi-colon (;)
How do you add a comment?
Add “–” before
Order of operations?
Parentheses
Multiplication / division
Addition / subtraction
SELECT clause
Returns a result set of records from one or more tables
Most commonly used DML command
SELECT DISTINCT
Removes duplicate values
WHERE clause
Used to filter data
Comparison Operators
> , >=
!=
Logical Operators
Used with WHERE clause
AND (both conditions must be True)
OR (at least one condition must be True)
NOT (to negate a condition)
IN Operator
Returns values in any of specified values
Example:
WHERE state IN (‘VA’, ‘NY’, ‘CA’)
BETWEEN Operator
WHERE points BETWEEN 100 AND 200
Inclusive of the values provided
LIKE Operator
Used in the WHERE clause to search for a specified pattern in a column
WHERE first_name LIKE ‘b%’
WHERE first_name LIKE ‘%b’
WHERE first_name LIKE ‘b___’
First name starts with b and has any number of characters
First name ends with b and has any number of characters
First name starts with b and ends with exactly 3 characters
WHERE first_name REGEXP ‘ey$|on$’
Returns first names that end with EY or ON
WHERE first_name REGEXP ‘^a’
Returns first names that start with ‘a’