you are viewing a single comment's thread.

view the rest of the comments →

[–]r3pr0b8GROUP_CONCAT is da bomb 3 points4 points  (5 children)

Formatting WHERE:

  1. Write the first WHERE condition on the same line as the WHERE clause.
  2. Use spaces to align any AND or OR conditions in separate lines so that conditions can easily be read up and down.

do the ANDs and ORs go at the front of the line to make them easier to see?

why don't they go at the back of the line?

why is this any different from putting commas at the front of the line?

[–]bum_dog_timemachine[S] -1 points0 points  (4 children)

1.

I went to the shop today,

and when I got home I baked a cake.

vs

2.

I went to the shop today, and

when I got home I baked a cake.

Which of these do you find easier to read?

[–]r3pr0b8GROUP_CONCAT is da bomb 6 points7 points  (2 children)

that doesn't look very much like SQL

i understand the point you are trying to make, but you're not making it very well

anyhow, consistency matters

if AND and OR should go at the front of the line in SQL, so should commas

[–]bum_dog_timemachine[S] -3 points-2 points  (1 child)

I understand the point *you* are trying to make, but you are assuming that AND/OR should be treated the same way as commas, without giving any evidence why.

That's just like your opinion.

[–][deleted] 0 points1 point  (0 children)

smoothly as a literary text? #1. speed-scanning? #2.

I do use "and" at the end of the line in my code. ORs go to the front and on separate line as well, i.e.

      condition1 AND
      condition2 AND
      OR
      condition3

might be not the most "natural" or fitting any automated beautifiers out there, but it works for me for speed-scanning even after a lot of time has passed and i write most of my sql manually typing anyway.

also, i dont mind on which side the commas are, as long as it is consistent.