Show Menu
Cheatography
This is a draft cheat sheet. It is a work in progress and is not finished yet.

QUERYING DATA

SELECT c1, c2 FROM t;

Query data in columns c1, c2 from the table t

SELECT * FROM t;

Query data from all columns from the table t

SORTING DATA

SELECT c1, c2 FROM t ORDER BY c1 [ASC | DESC];

Sorts the result by data in column c1 in ascending or descending order

Keywords ASC and DESC are optional - ASC will be used by default if order is not specified

FILTERING DATA

SELECT DISTINCT c1 FROM t;
DISTINCT is used to select only unique values

if more then one column are listed after DISTINCT keyword then the combin­ation of these columns will be used in duplicates evaluation
 

JOINS

f
1
g
2