Skip to content

Latest commit

 

History

History
45 lines (32 loc) · 584 Bytes

SQL-CHEATSHEET.md

File metadata and controls

45 lines (32 loc) · 584 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