Show Menu
Cheatography

SQL Select Cheat Sheet (DRAFT) by

SQL Select Basics

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

Rangfolge

SELECT [ DISTINCT | ALL ]
FROM Tabelle [AS Alias]
JOIN .. ON
[WHERE]
[ GROUP BY]
[HAVING]
[ UNION [ALL] ]
[ ORDER BY]

ORDER BY

ASC (Standart)
Aufste­igend
DESC
Absteigend
 
ORDER BY plz DESC, name

Mengen­ope­rat­ionen

UNION
Verein­igung
INTERSECT
Duchsc­hnitt -> Datens­ätze, die in beiden Mengen vorhanden sind
EXEPT / Minus
Differenz -> Alle die in Tabelle A, aber NICHT in Tabelle B vorhanden sind
 

Aggreg­etf­unk­tionen

COUNT(*)
Anzahl
SUM(*)
Summe
AVG(*)
Durchs­chnitt
MIN() / MAX()
Minimum / Maximum
VAR(*)
Varianz
STDEV(*)
Standa­rta­bwe­ichung

WHERE

= < > <= => <>
WHERE id > 3
BETWEEN
WHERE id BETWEEN 40 AND 50
NOT BETWEEN
WHERE ID NOT BETWEEN 40 AND 50
LIKE
WHERE name LIKE 'B%'
 
WHERE name LIKE '%alt%'
 
WHERE name LIKE '_eier'
ISNULL
WHERE telefon IS NULL
 
WHERE telefon IS NOT NULL
IN
WHERE farbe IN ('Grün­','­Gelb')
 
WHERE farbe IN (SELECT ...)
NOT
WHERE NOT (id >100)
AND
WHERE id > 100 AND farbe = 'blau'
OR
WHERE id < 100 OR farbe=­'blau'
XOR
True, wenn genau ein Wert wahr und ein Wert falsch ist