The Complete SQL Bootcamp for the Manipulation and Analysis of Data | Udemy
SELECT: most common statement used to retrieve information from a table
- SELECT column_name FROM table_name
- using * instead of the column name retrieves all the columns
- separate column names by a comma for multiple columns
- using capital letters for SQL keywords helps with visualization
SELECT DISTINCT: used to return distinct values in columns
- SELECT DISTINCT column_name FROM table_name
- parenthesis can be used around column name for better clarity
COUNT: returns the number of input rows that match a specific condition of a query
- SELECT COUNT (column_name/results) FROM table_name;
- needs parenthesis
- SELECT COUNT(*) FROM table_name
- returns the number of rows in a table
- more useful when used with keywords like DISTINCT
SELECT WHERE: allows to specify conditions on columns for the rows to be returned (filtering
- SELECT column_names FROM table_names WHERE conditions
- Comparison operators
- =,>,<,>=,<=, (<> or !=)
- Logical operators
- AND, OR, NOT
ORDER BY: sort rows based on a column value (ascending or descending)
- SELECT columns FROM table ORDER BY columns ASC/DESC
LIMIT: limit the number of rows returned for a query
- LIMIT num_of_rows
- only viewing a few rows to get an idea of the table
- useful with ORDER BY
- goes to the end of the query
BETWEEN: used to match a value against a range of values
- value BETWEEN low AND high
- inclusive
- can be used with dates when it is in YYYY-MM-DD format
IN: creates a condition to check if a value is included in a list of options
- value IN (option1, option2, option3, option_n)
LIKE: pattern matching with string data using wildcard characters
- %
- matches any sequence of characters
- putting % in the back of the character is looking for matching in the beginning, and vice versa
- _
- matches any single character (replacing a single character)
- can use multiple underscores
ILIKE: case-insensitive version of LIKE
'Development > SQL' 카테고리의 다른 글
[SQL 배우기] Section 8. Creating Databases and Tables (1) | 2024.03.12 |
---|---|
[SQL 배우기] Section 6. Advanced SQL Commands (0) | 2024.03.12 |
[SQL 배우기] Section 5. JOINS (0) | 2024.03.12 |
[SQL 배우기] Section 3. GROUP BY Statements (0) | 2024.03.12 |
[SQL 배우기] Section 1. Course Introduction (0) | 2024.03.12 |