 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
mksql
Joined: 29 Dec 2006 Posts: 19 Country: United States |
|
SQL Formatting: Left justifying joins |
|
I am attempting to create a formatting pattern for SELECTs that indents join terms on their own lines, with each JOIN keyword left justified:
 |
 |
SELECT col1,
col2,
FROM table1 t1
INNER JOIN table2 t2 on t1.id = t2.id
AND t2.cdate > GETDATE()
LEFT OUTER JOIN table3 t3 on t3.id = t2.id
|
However the second join in this example follows the indent of the previous line:
 |
 |
SELECT col1,
col2,
FROM table1 t1
INNER JOIN table2 t2 ON t1.id = t2.id
AND t2.a > 10
LEFT OUTER JOIN table3 t3 ON t3.id = t2.id
|
My format tempate is below. What is incorrect in the template?:
 |
 |
SELECT ... AS ...,
... = ...,
... (..., ...)
FROM ... AS ...,
... JOIN ... ON ... = ...
AND ...,
(...)
WHERE ... = ...
AND ...
OR (...)
GROUP BY
...,
(...)
HAVING ...,
(...)
ORDER BY
...,
(...)
|
|
|
Thu Oct 04, 2007 10:36 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
Try this
 |
 |
SELECT ... AS ...,
... = ...,
... (..., ...)
FROM ... AS ...
JOIN ... ON ... = ...
AND ...
WHERE ... = ...
AND ...
OR (...)
GROUP BY
...,
(...)
HAVING ...,
(...)
ORDER BY
...,
(...) |
|
|
Thu Oct 04, 2007 3:25 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
By the way, version 3 will support multiple formatting styles.
|
|
Thu Oct 04, 2007 3:33 pm |
|
 |
mksql
Joined: 29 Dec 2006 Posts: 19 Country: United States |
|
|
|
That template gives me this output:
 |
 |
SELECT col1,
col2,
FROM table1 t1
INNER
JOIN table2 t2 ON t1.id = t2.id
AND t2.cdate > GETDATE()
LEFT OUTER
JOIN table3 t3 ON t3.id = t2.id
|
|
|
Thu Oct 04, 2007 6:11 pm |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|