organization:sql_code_standards
This is an old revision of the document!
SQL code layout: Here's a sample of how ideally SQL code should look. Note where the lines break, the capitalization, and the use of brackets.
Examples:
SELECT field1 AS something, field2, field3
FROM (table a, table b)
WHERE (this = that) AND (this2 = that2)
This is valid too however:
SELECT field1 AS something, field2, field3 FROM (table a, table b) WHERE (this = that) AND (this2 = that2)
ALWAYS enclose FROM tables into brackets – for LEFT JOIN compatability in MYSQL 5+.
SQL insert statements: SQL INSERT statements should be written LIKE UPDATE statemnets.
Examples:
# This is not what we want.
INSERT INTO mytable
VALUES ('something', 1, 'else')
# This is correct.
INSERT INTO mytable SET column1='something', column2=1, column3='else'
organization/sql_code_standards.1441781509.txt.gz · Last modified: (external edit)
