How to indent SQL statements?
-
Hello, I have made a search but could not find how to indent correctly SQL statements. For instance; SELECT * FROM a WHERE att1 IN ( SELECT att8 FROM b WHERE att2 = 10 AND att3 = 20 AND att4 = 30 GROUP BY att8 HAVING count(*) > 3 ) How this sample statement can be indented correctly(standard way)? Any opinion or any article would be appriciated. Kind Regards, Sarp
-
Hello, I have made a search but could not find how to indent correctly SQL statements. For instance; SELECT * FROM a WHERE att1 IN ( SELECT att8 FROM b WHERE att2 = 10 AND att3 = 20 AND att4 = 30 GROUP BY att8 HAVING count(*) > 3 ) How this sample statement can be indented correctly(standard way)? Any opinion or any article would be appriciated. Kind Regards, Sarp
I've not come across a standard way of doing this. My particular scheme is something like this:
SELECT Column1, Column2, Column3
FROM MyTable AS mt
INNER JOIN SomeOtherTable AS sot ON mt.pk = sot.fk
INNER JOIN (SELECT fk, ColumnA, ColumnB, ColumnC
FROM InnerTable
WHERE ColumnD = 10) AS it ON mt.pk = it.fk
WHERE mt.Column4 IS NOT NULL
ORDER BY Column2;ColinMackay.net Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
-
I've not come across a standard way of doing this. My particular scheme is something like this:
SELECT Column1, Column2, Column3
FROM MyTable AS mt
INNER JOIN SomeOtherTable AS sot ON mt.pk = sot.fk
INNER JOIN (SELECT fk, ColumnA, ColumnB, ColumnC
FROM InnerTable
WHERE ColumnD = 10) AS it ON mt.pk = it.fk
WHERE mt.Column4 IS NOT NULL
ORDER BY Column2;ColinMackay.net Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
-
I've not come across a standard way of doing this. My particular scheme is something like this:
SELECT Column1, Column2, Column3
FROM MyTable AS mt
INNER JOIN SomeOtherTable AS sot ON mt.pk = sot.fk
INNER JOIN (SELECT fk, ColumnA, ColumnB, ColumnC
FROM InnerTable
WHERE ColumnD = 10) AS it ON mt.pk = it.fk
WHERE mt.Column4 IS NOT NULL
ORDER BY Column2;ColinMackay.net Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
Colin Angus Mackay wrote:
My particular scheme is something like
I do the same here. My old Oracle book from my undergraduate database course does it this way. PJC
-
Colin Angus Mackay wrote:
My particular scheme is something like
I do the same here. My old Oracle book from my undergraduate database course does it this way. PJC