SQL Format, Part 3 of 4
This statement with extra spaces, tabs, and carriage returns, is difficult to read but it will execute properly:
SELECT
CUST_ID,
CUST_NAME
FROM
CUSTOMER_TBL;
Or you could write the statement on one line:
SELECT CUST_ID, CUST_NAME FROM CUSTOMER_TBL;
This is the same statement in a more proper format:
SELECT CUST_ID,
CUST_NAME
FROM CUSTOMER_TBL;
Here are some rules for making your statements readable:
> Always begin a new line with each clause in the statement.
> Use spaces or tabs for indentation when arguments of a clause exceed one entry.
> Begin a new line with each column name in the SELECT clause.
> Begin a new line with each table name in the FROM clause.
> Begin a new line with each condition in the WHERE clause.
> Use spaces and tabs consistently.
> Use table aliases when multiple tables are used.
> Use remarks sparingly if they are allowed in your implementation.