1๏ธโฃ SELECT, FROM, WHERE
This is how you tell SQL what data you want, where to get it from, and how to filter it.
๐ SELECT = what columns
๐ FROM = which table
๐ WHERE = which rows
Example:
SELECT name, age FROM employees WHERE age > 30; This shows names and ages of employees older than 30.
2๏ธโฃ ORDER BY, LIMIT
Use when you want sorted results or only a few records.
๐ ORDER BY sorts data
๐ LIMIT reduces how many rows you get
Example:
SELECT name, salary FROM employees ORDER BY salary DESC LIMIT 3; Shows top 3 highest paid employees.
3๏ธโฃ DISTINCT
Removes duplicate values from a column.
Example:
SELECT DISTINCT department FROM employees; Lists all unique departments from the employees table.
4๏ธโฃ BETWEEN
Used for filtering within a range (numbers, dates, etc).
Example:
SELECT name FROM employees WHERE age BETWEEN 25 AND 35; Shows names of employees aged 25 to 35.
5๏ธโฃ IN
Use IN to match against multiple values in one go.
Example:
SELECT name FROM employees WHERE department IN ('HR', 'Sales'); Shows names of people working in HR or Sales.
6๏ธโฃ LIKE
Used to match text patterns.
๐ % = wildcard (any text)
Example:
SELECT name FROM employees WHERE name LIKE 'A%'; Finds names starting with A.
๐ฌ Double Tap โค๏ธ if this helped you!