Treating AND and OR in JOIN clause differently than in WHERE
anacap
Posts: 3 New member
in SQL Prompt
I currently like to format my AND and OR keywords on a new line indented in my WHERE clause but want them on the same line when I'm joining two tables on multiple columns. The current behavior treats them no differently and if I join two tables on more than one column, the second (or more) columns are put on their own lines. If there's no current way to do this, is there a possibility this will be addressed in a future version?
Tagged:
Answers
Dan Jary | Redgate Software
Have you visited our Help Center?
SELECT a.Col1,
b.Col2
FROM dbo.Table1 a
INNER JOIN dbo.Table2 b ON a.Col3 = b.Col3 AND a.Col4 = b.Col4
WHERE a.Col5 = 3
AND b.Col6 = 5;
Currently there is no distinction for the AND in the JOIN clause and the current behavior is to place the first AND on the next line (the way it is in the WHERE clause).
It would be nice to have a distinction there. I personally like having my joined tables and how they are joined all on one line so I can quickly see how many joined tables/views are involved.
Dan Jary | Redgate Software
Have you visited our Help Center?
I want the FROM clause to look the way it does in your sample code. That part looks how I would like it. However, the WHERE clause is all on one line which is not what I like it to be.
It seems the Operators section in the style formatting should appear twice: Under Clauses-JOIN and create another: Clauses-WHERE and then offer AND/OR options. Then what I would do is for Clauses-JOIN is set Place On New Line to NEVER and in Clauses-WHERE set Place On New Line to Always with Alignment set to To First List Item.
Or perhaps just have one setting under Clauses-JOIN and a checkbox to that says, "Keep all JOIHN conditions on the same line as Table/View"
Dan Jary | Redgate Software
Have you visited our Help Center?