Skip to content

Commit 1c40ff5

Browse files
authored
Merge pull request #191 from inbo/fredericpiesschaert-patch-2
some remarks by Floris
2 parents 3f92239 + ffa8ef7 commit 1c40ff5

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

  • content/tutorials/sql_styleguide

content/tutorials/sql_styleguide/index.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ SQL is a standard language for storing, manipulating and retrieving data in data
2222
**/
2323
2424
SELECT w.WRNG_JAR AS jaar
25-
, w.WRNG_UTM1_CDE AS UTM1
25+
, w.WRNG_UTM1_CDE AS utm1
2626
, s.SPEC_NAM_WET AS wetenschappelijke_naam
2727
, s.SPEC_NAM_NED AS nederlandse_naam
2828
, t.TOPO_DES AS locatie
2929
FROM tblWaarneming w
3030
INNER JOIN tblWaarnemingMeting wm ON w.WRNG_ID = wm.WRME_WRNG_ID
3131
INNER JOIN tblSoort s ON wm.WRME_SPEC_CDE = s.SPEC_CDE
3232
LEFT JOIN tblToponiem t on t.TOPO_ID = w.WRNG_TOPO_ID --toponiemen werden niet altijd ingevuld
33-
WHERE 1=1
33+
WHERE 1 = 1
3434
AND w.WRNG_UTM1_CDE IS NOT NULL
3535
AND w.WRNG_JAR > 2010
3636
GROUP BY w.WRNG_JAR
@@ -44,14 +44,15 @@ SQL is a standard language for storing, manipulating and retrieving data in data
4444

4545
* SQL-keywords (SELECT, FROM, JOIN, WHERE, GROUP BY, ...) are written in capitals
4646
* Table names and field names are capitalized as they are defined in the database
47-
* Use short and meaningfull aliases and write them in lowercase
47+
* Use short and meaningful aliases and write them in lowercase
4848
* Use a new line for each field in the SELECT-statement and each argument in the WHERE and GROUP BY clause
4949
* Put the comma in front of the line in SELECT and GROUP BY statements
5050
* Indent each field in the SELECT-statement and each argument in the WHERE and GROUP BY clause
5151
* When multiple arguments are used in the WHERE clause, AND/OR keywords are always placed at the front
5252
* Use full INNER JOIN statements
5353
* JOINS should be indented
5454
* Subqueries should be indented and properly named
55+
* Put whitespaces around relational operators (= > ...)
5556
* Document your scripts
5657

5758

@@ -108,7 +109,7 @@ SQL is a standard language for storing, manipulating and retrieving data in data
108109
WHERE P.age > 50
109110
```
110111
111-
* Table aliases are short and meaningfull in the context of the query
112+
* Table aliases are short and meaningful in the context of the query
112113
113114
```
114115
--Good
@@ -415,7 +416,7 @@ SQL is a standard language for storing, manipulating and retrieving data in data
415416
416417
* Use TOP 10 (or LIMIT 10 in Postgres) when designing queries with a large resultset (taking a long time to run). It saves a lot of time in the design stage.
417418
418-
* Use 1=1 as the first line of the WHERE clause. This allows you to easily turn on and off all restrictions while designing your query. Beware of OR: where 1=1 OR age>50 doesn’t mean that everybody is +50.
419+
* Use 1 = 1 as the first line of the WHERE clause. This allows you to easily turn on and off all restrictions while designing your query. Beware of OR: where 1 = 1 OR age > 50 doesn’t mean that everybody is +50.
419420
420421
421422
```
@@ -426,7 +427,7 @@ SQL is a standard language for storing, manipulating and retrieving data in data
426427
, a.city
427428
FROM person p
428429
INNER JOIN address a ON a.personid = p.id
429-
WHERE 1=1
430+
WHERE 1 = 1
430431
--AND p.age > 50
431432
AND a.city like ‘Ar%’
432433

0 commit comments

Comments
 (0)