Skip to content

Latest commit

 

History

History
50 lines (34 loc) · 595 Bytes

SQL-CHEATSHEET.md

File metadata and controls

50 lines (34 loc) · 595 Bytes

SQL Cheatsheet

Queries

Specify what information to extract

SELECT column

From which table

FROM table

Only extract rows where the condition holds

(Used with an operator: >, <, >=, <=, =, <>, BETWEEN, LIKE, IN)

WHERE column = 'value'

Combining WHERE clauses:

(Used with: AND, OR)

WHERE column = 'value' OR
      column = 'other value'

Aggregating results:

(Used with: SUM, COUNT, MIN, MAX, AVG)

SELECT
    SUM(column)
FROM table

Aliasing tables

SELECT
    column AS alias
FROM table