Hi guys, this is the first day I learn IT (officially). I decide to take notes about whatever I think important and related. Hopefully I can form a network of knowledge one day.
It would be so ideal if someone read my posts and help me improve. All suggestions are welcomed. Learning is detemined to be a road of loneliness, but one will go further with other lonely geeks. That's what I thought the meaning of communities.
1. SELECT Statement:
- The
SELECT
statement is used to retrieve data from one or more tables.
SELECT column1, column2
FROM table_name;
2. FROM Clause:
- The
FROM
clause specifies the table or tables from which to retrieve data.
SELECT column1, column2
FROM employees;
3. WHERE Clause:
- The
WHERE
clause is used to filter rows based on specific conditions.
SELECT column1, column2
FROM table_name
WHERE condition;
4. AND, OR, NOT Operators:
- Combine conditions using
AND
,OR
, andNOT
operators in theWHERE
clause.
SELECT column1, column2
FROM table_name
WHERE condition1 AND condition2;
5. ORDER BY Clause:
- The
ORDER BY
clause is used to sort the result set based on one or more columns.
SELECT column1, column2
FROM table_name
ORDER BY column1 ASC;
6. INSERT INTO Statement:
- The
INSERT INTO
statement is used to insert new records into a table.
INSERT INTO table_name (column1, column2)
VALUES (value1, value2);
7. UPDATE Statement:
- The
UPDATE
statement is used to modify existing records in a table.
UPDATE table_name
SET column1 = value1, column2 = value2
WHERE condition;
8. DELETE Statement:
- The
DELETE
statement is used to remove records from a table.
DELETE FROM table_name
WHERE condition;
9. JOIN Clause:
- The
JOIN
clause is used to combine rows from two or more tables based on a related column.
SELECT column1, column2
FROM table1
INNER JOIN table2 ON table1.column = table2.column;
10. GROUP BY Clause:
- The `GROUP BY` clause is used to group rows based on one or more columns, often used with aggregate functions.
```sql
SELECT column1, COUNT(*)
FROM table_name
GROUP BY column1;
```
11. HAVING Clause:
- The `HAVING` clause is used with the `GROUP BY` clause to filter the results based on aggregate values.
```sql
SELECT column1, COUNT(*)
FROM table_name
GROUP BY column1
HAVING COUNT(*) > 10;
```
12. Aliases:
- Use aliases to provide temporary names for columns or tables in your queries.
```sql
SELECT column1 AS alias1, column2 AS alias2
FROM table_name;
```
13. Comments:
- Use `--` for single-line comments or `/* */` for multi-line comments.
```sql
-- This is a single-line comment
/*
This is a
multi-line comment
*/
```
Top comments (0)