SQL Statement indentation good practice [closed]

2019-01-21 05:06发布

What is the accepted practice for indenting SQL statements? For example, consider the following SQL statement:

SELECT column1, column2
FROM table1
WHERE column3 IN
(
SELECT TOP(1) column4
FROM table2
INNER JOIN table3
ON table2.column1 = table3.column1
)

How should this be indented? Many thanks.

25条回答
爷的心禁止访问
2楼-- · 2019-01-21 06:09

I like to have "rivers" of white space in the code. It makes it a little easier to scan.

SELECT column1,
       column2
  FROM table1
 WHERE column3 IN (SELECT column4
                     FROM table2
                     JOIN table3
                       ON table2.column1 = table3.column1);
查看更多
登录 后发表回答