My SQL Map
My SQL Map
1. SQL Basics
- SQL Syntax: Basic SQL commands like SELECT, INSERT, UPDATE, DELETE.
Example:
- Data Types: Common data types include INT, VARCHAR, DATE, etc.
Example:
Example:
Example:
- Basic Operators: SQL has comparison (e.g., =, <, >) and logical operators (e.g., AND, OR).
Example:
SELECT * FROM Employees WHERE Salary > 50000 AND Department = 'IT';
- INNER JOIN: Combines rows from two or more tables based on a related column.
Example:
Departments.DepartmentID;
- LEFT JOIN: Retrieves all records from the left table, and matched records from the right table.
Example:
Departments.DepartmentID;
- Primary and Foreign Keys: Used to uniquely identify rows and enforce relationships.
Example:
DepartmentName VARCHAR(100)
);
Name VARCHAR(100),
DepartmentID INT,
);
3. Aggregate Functions
Example:
Example:
- GROUP BY: Groups rows that share a property, often used with aggregate functions.
Example:
Example:
4. Subqueries
Example:
Example:
SELECT Name, Salary FROM Employees E WHERE Salary > (SELECT AVG(Salary) FROM
5. Set Operations
Example:
SELECT Name FROM Employees UNION ALL SELECT Name FROM Contractors;